/* File: min3.c Report the smallest item entered by the user. Another alternate form. */ #include int main() { int min, n, count ; printf("Enter some numbers. When you are done, type 'quit'.\n") ; // Sepcial case for the first number, to initialize the min. printf("? ") ; count = scanf("%d", &n) ; if (count == 0) { printf("No numbers entered!\n") ; return 0 ; // exit from main() } min = n ; // initially, first number is smallest. while (1) { // loop until a break printf("? ") ; count = scanf("%d", &n) ; if (count == 0) break ; if (n < min) min = n; // debug // printf("*** Current smallest number = %d ***\n", min) ; } printf("The smallest number is: %d\n", min) ; return 0 ; }