Question: Input 100 please! (1) Read integer 100 from the keyboard. The program will keep asking for 100 if the user gives a different number (let's

 Input 100 please! (1) Read integer 100 from the keyboard. Theprogram will keep asking for 100 if the user gives a different

Input 100 please! (1) Read integer 100 from the keyboard. The program will keep asking for 100 if the user gives a different number (let's assume only integers will be entered for now), e.g, Please enter 100: 99 I'm sorry, you must enter 100: 101 I'm sorry, you must enter 100: 100 Got 100! (2) Assume the user may enter non-integer characters like "abcd". (a) use the return value of scanf function to detect; and (b) call clearKeyboardBuffer( to remove the non-integer characters before reading new input Please enter 100: abcde I'm sorry, you must enter 100: ok I'm sorry, you must enter 100: 100 Got 100! 5 #include 6 7 int main(int argc, char* argv[]) { 8 int input; 9 printf("Please enter 100: "); 11 scanf("%d", &input); 12 13 14 printf("Got %d! ", input); 15 return 0; 10 16 }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!