How to print only one time the statement if a few wrong input is key in:
Eg:
if key in kkk, only will print one statement instead of the example below.
sample output:
Do you wish to try again (Type Y to continue Q to quit:kkk
Error: Invalid choice
Do you wish to try again (Type Y to continue Q to quit:Error: Invalid choice
Do you wish to try again (Type Y to continue Q to quit:Error: Invalid choice
Do you wish to try again (Type Y to continue Q to quit:
//Code
valid=0;
while (valid==0)
{
printf("\nDo you wish to try again (Type Y to continue Q to quit:"); // print statement request for input
scanf(" %c", &choice); // get user input
choice = toupper(choice);
if((choice == 'Y') || (choice == 'Q')) valid= 1;
else printf("Error: Invalid choice\n"); // statement
}
The answer to the question is available in the PDF file https://www.assignmentexpert.com/https://www.assignmentexpert.com/homework-answers/programming-answer-62455.pdf
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment