Ask Question
29 May, 06:44

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
Answers (1)
  1. 29 May, 07:26
    0
    The code to this question as follows:

    Code:

    do{ / /do-while loop

    cin >> c; / /input value from user.

    }while (! (c = = 'Y' || c = = 'y' || c=='N' || c = = 'n')); / /check condition.

    Explanation:

    The description of the code as follows:

    In this code, we use a do-while loop. It is an exit control loop. In the loop, we use the char variable that is "c" this variable is used for user input. End of the loop we define the condition that is variable c value is not equal to "y", "Y", "n" and "N". In the loop, we use OR operator that means if any of the above conditions is match it will terminate the loop.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “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 ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers