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;
}