Given a char variable c that has already been declared , write some code that repeatedly reads a value from standard input into c until at last a ‘Y’ or ‘y’ or ‘N’ or ‘n’ has been entered.

1
Given a char  variable c that has already been declared , write some code that repeatedly reads a value from standard input into c until at last a ‘Y’ or ‘y’ or ‘N’ or ‘n’ has been entered.

LANGUAGE: C++

CHALLENGE:

Given a char variable c that has already been declared , write some code that repeatedly reads a value from standard input into c until at last a ‘Y’ or ‘y’ or ‘N’ or ‘n’ has been entered.

SOLUTION:


while ( c!='Y' && c!='y' && c!='n' && c!='N') {
    	cin >> c;
}

One comment

Add comment