60 438
Assignments Done
98,1%
Successfully Done
In April 2018

Answer to Question #62455 in C for LEE JIA WEI

Question #62455
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
}
Expert's answer

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions