
November 14th, 2002, 07:44 AM
|
|
Junior Member
|
|
Join Date: May 2002
Posts: 12
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
loop problem
having a problem with this small c++ program im writing.
i'm getting an error saying Lvalue required at the first while statement
this program loops printing just the message until the user enter 'n' or 'N'. If the user enters a character other than 'n' , 'N' , 'y' , 'Y' the message invalid selection is entered and the prompt should be redisplayed
can anyone please help?
#include <iostream.h>
# include <stdlib.h>
char ch;
void main()
{
while (ch=!'n' || ch=!'N')
{
cout << "Do you really want to run this program? (yes/no)\n ";
cin >> ch ;
if (ch!='y' || ch!='Y' || ch!='n' || ch!='N')
{
cout << "Invalid selection\n" ;
}
}
if (ch=='n' || ch=='N')
{
exit(1);
}
}
|