Ask Question
24 July, 10:04

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. 24 July, 10:23
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers