There is little mistakes in this program. I couldnot understand.
may be you can see.

For example ı can not solve exit problem in menu function

#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')
    return;     //  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;
     }

I suggest simplifying this code as much as possible. That is, we don't need to see the encryption function at all to look for this problem. Typically by doing this, you will be able to see the problem yourself :)

Also, explain the input, expected output, and current output.

okey.
ı want to quit proqram when ı press to q or Q

ı want to encyrpt and decyrpt some numbers. my formulas can be true . but ı suppose that ı could not write my function truthfully


errors=
ln function void 'menu()'
expected before "return"

#
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')
#
return; // when key is q , it should quit program
#
}

>>while (a!='q' || a!='Q')

Use && operator instead of ||. Read it as "while a not equal to 'q' and not equal to 'Q'"


>>expected before "return"

I think you will need a semicolon at the end of that line too because its the end of a do loop

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.