Ask Question
29 January, 04:58

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.

+4
Answers (1)
  1. 29 January, 05:41
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers