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
Comments
Leave a comment