What is wrong with this program? I want it to loop until the user enters Yy for yes and Nn for no. I can't figure it out.
int Ask()
{
char cAnswer = 0;
int iCount = 0; //Counts which number cell user is on
while (cAnswer!='y'||cAnswer!='Y') //Run while loop until n or N
{
cout<<"Do you wish to enter a number? (Y/N): ";
cin>>cAnswer;
if (cAnswer=='y'||cAnswer=='Y')
{
iCount++;
Number(iCount);
}
if (cAnswer=='n'||cAnswer=='N')
{
return 1;
}
else
{
cout<<"Please only enter y or n "<<endl;
}
}
}
I'm just talking about the while loop. Any help is appreciated. I'm actually a pretty programmer but the post don't seem to show tabs.
int Ask()
{
char cAnswer = 0;
int iCount = 0; //Counts which number cell user is on
while (cAnswer!='y'||cAnswer!='Y') //Run while loop until n or N
{
cout<<"Do you wish to enter a number? (Y/N): ";
cin>>cAnswer;
if (cAnswer=='y'||cAnswer=='Y')
{
iCount++;
Number(iCount);
}
if (cAnswer=='n'||cAnswer=='N')
{
return 1;
}
else
{
cout<<"Please only enter y or n "<<endl;
}
}
}
I'm just talking about the while loop. Any help is appreciated. I'm actually a pretty programmer but the post don't seem to show tabs.
