ı could not solve non lvalue assignment problem in this example
I thought for long time but ı could not find any answer
if you can help me , ı would be very happy

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')
cout<<"...";
}

void encyrpt (void)
{
int num,a,b,c,d,e;
char f,g;
cout<<"the 4-digit integer to be encrypted"<<endl;
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;
cout<<"Encrypted integer "<<a<<c<<e<<f<<endl;
cout<<"Do you want to encrypt another integer? (y/n) :"<<endl;
}
int main(void)
{
menu();

return 0;

}

Recommended Answers

All 2 Replies

>>if ( 'a'=!'e' || 'a'=!'d' || 'a'=!'E' || 'a'=!'D')

remove the quotes around variable a if ( a=!'e' || a=!'d' || a=!'E' || a=!'D') and not equal is !=

You want to use && and operator, not or operator. Using or in that statement will cause it to always return true regardless of the value of a.

thanks your attention:)

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.