Title:
Requires a a,b,c three integer variable to store the user input 3 values.
See Program implementation:
#include <stdio.h>intMain () {intA =0, B =0, C =0; while((A * b *c <1&& (a<1|| b<1|| c<1)) && (scanf ("%d%d%d", &a, &b, &c) <=3) {fflush (stdin); }; printf ("%d%d%d\n", A, b, c); return 0;}The scanf function returns a value of type int. If both A and B are read successfully, then the return value of the scanf is 2, and if only a is read successfully, the return value is 1, if both A and B are not successfully read, the return value is 0, and if an error is encountered or an end of file is encountered, the return value is EOF. End of file is CTRL + Z or Ctrl+d
Flexible use of the return value of the scanf can be more efficient with the data entered by the user, and will not cause the entire program to run because of an error in the input.
Use the while loop to get user input and get the data again when the condition is not met. Until the data entered by the user is valid and then stopped,
In a cyclic read, use Fflush (stdin) to flush the standard input buffer and discard anything in the input buffer.
Note: A good algorithm design to ensure the robustness of the program, and sometimes can be in the case of defective data can still give the correct results.
SCANF control the legal range of user input data _ algorithm _c language