This is my encyription and decyrption program. However there some mistakes that ı could not solve them.
And ı set everything but when ı press q, my program should quit, ı tried some things but it is not appropriate for c++ rules.

#include <iostream>
using namespace std;
void encyrpt(void);
void decyrpt(void);
void menu(void)
{
char a;

cout<<"(E/e) Encryption"<<endl;
cout<<"(D/d) Decryption"<<endl;
cout<< "(Q/q) Quit"<<endl;

cout<<"Enter operation code :";
cin>>a;

if ( a!='e' || a!='d' || a!='E' || a!='D')
cout<<"/n you entered an invalid operation code"<<endl;
else if ( a=='e' || a=='E')
encyrpt();
else if (a=='d' || a=='D')
decyrpt();

else if (a=='q' || a=='Q')


/// when key is q , it should quit program
}

void encyrpt (void)
{
int num,a,b,c,d,e,f;
char g,h;
cout<<"the 4-digit integer to be encrypted"<<endl;
cin>>num;

if (num<=999 || num>=10000) // buraya loop yapılması lazım
cout<<" You entered an invalid integer!"<<endl;
else
a=num/1000;
b=num%1000;
c=b/100;
d=b%100;
e=d/10;
f=d%10;
cout<<"Encrypted integer "<<a<<c<<e<<f<<endl;
cout<<"Do you want to encrypt another integer? (y/n) :"<<endl;
do
{
cin>>h;
if(h=='y')
encyrpt();
else if (h=='n')
menu();
}
while(h!='y' || h!='n')

}

void decyrpt(void)
{
int num,a,b,c,d,e,f,m,n,r,k;
char h;

cout<<"the 4-digit integer to be decrypted"<<endl;

if (num<=999 || num>=10000)
cout<<" You entered an invalid integer!"<<endl;

else
a=num/1000;
b=num%1000;
c=b/100;
d=b%100;
e=d/10;
f=d%10;

k=(10+f)/2;
r=( (10+e-f)%10);
n=( (10+c-f)%10);
m=( (10+a-f)%10);

cout<<"Decrypted integer is "<< m<<n<<r<<k<<endl;
cout<<"Do you want to encrypt another integer? (y/n) :"<<endl;
do
{
cin>>h;
if(h=='y')
decyrpt();
else if (h=='n')
menu();
}
while(h!='y' || h!='n')
}
int main(void)
{
menu();
return 0;

}

Not sure you copied all the code but if your comment is all that is in the if else block then you got a syntax error:
should be like

void menu(void)
{
char a;

cout<<"(E/e) Encryption"<<endl;
cout<<"(D/d) Decryption"<<endl;
cout<< "(Q/q) Quit"<<endl;

cout<<"Enter operation code :";
cin>>a;

if ( a!='e' || a!='d' || a!='E' || a!='D')
cout<<"/n you entered an invalid operation code"<<endl;
else if ( a=='e' || a=='E')
encyrpt();
else if (a=='d' || a=='D')
decyrpt();

else if (a=='q' || a=='Q')
[B]return;[/B]/// when key is q , it should quit program
}

Thisi is an encyrpt and decyrpt program . ı finished generally most of things of this program . However. there are some problems that ı couldon solved.
I know that these are very little problems . May be you can see

errors:
ln function 'void menu()'
expected before "cout"

#include <iostream>
using namespace std;
void encyrpt(void);
void decyrpt(void);
void menu(void) // this function provide to be reached to menu
{
char a;

cout<<"(E/e) Encryption"<<endl;
cout<<"(D/d) Decryption"<<endl;
cout<< "(Q/q) Quit"<<endl;

cout<<"Enter operation code :";
do
{
cin>>a;

if ( a!='e' || a!='d' || a!='E' || a!='D') // with respect to election , program will be redirecting encyrpt ot decyrpt
cout<<"/n you entered an invalid operation code"<<endl;
else if ( a=='e' || a=='E')
encyrpt();
else if (a=='d' || a=='D')
decyrpt();
}
while (a!='q' || a!='Q')
cout<<" bye"<<endl;


/// when key is q , it should quit program

}

void encyrpt (void)
{
int num,a,b,c,d,e,f;
char g,h;
cout<<"the 4-digit integer to be encrypted"<<endl;


do
{
cin>>num;
if (num<=999 || num>=10000)
cout<<" You entered an invalid integer!"<<endl;
else
a=num/1000;
b=num%1000;
c=b/100; // this is encyription formula
d=b%100;
e=d/10;
f=d%10;
cout<<"Encrypted integer "<<a<<c<<e<<f<<endl;
cout<<"Do you want to encrypt another integer? (y/n) :"<<endl;
}
while (num<=999 || num>=10000);


do // if user enters wrong character, until user enters right character, program asks for right choice
{ //
cin>>h; //
if(h=='y') //
encyrpt(); //
else if (h=='n') //
menu(); //
}
while(h!='y' || h!='n');

}

void decyrpt(void) // decyrpt function
{
int num,a,b,c,d,e,f,m,n,r,k;
char h;

cout<<"the 4-digit integer to be decrypted"<<endl;
do
{
cin>>num;
if (num<=999 || num>=10000)
cout<<" You entered an invalid integer!"<<endl;

else
a=num/1000;
b=num%1000;
c=b/100;
d=b%100;
e=d/10;
f=d%10;

k=(10+f)/2;
r=( (10+e-f)%10);
n=( (10+c-f)%10);
m=( (10+a-f)%10);

cout<<"Decrypted integer is "<< m<<n<<r<<k<<endl;
cout<<"Do you want to encrypt another integer? (y/n) :"<<endl;
}
while (num<=999 || num>=10000);

do
{
cin>>h;
if(h=='y')
decyrpt();
else if (h=='n')
menu();
}
while(h!='y' || h!='n');
}

int main(void)
{
menu();
return 0;
}

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.