How would I compare a char? Say a do-while statement that checked if a char was equal to Y or y.
Printable View
How would I compare a char? Say a do-while statement that checked if a char was equal to Y or y.
-PreludeCode:do {
// Stuff
} while ( ch == 'Y' || ch == 'y' );
You can make life easier by converting to either upper or lower case..but dont forget to #include <ctype.h>
char ch;
do
{
cout << "enter letter";
cin >> ch;
ch=toupper(ch);
...
}while (ch=='Y');