/**************************************************************************** * beer-1.c * * David J. Malan * malan@harvard.edu * * Sings "99 Bottles of Beer on the Wall." * * Demonstrates a while loop. ***************************************************************************/ #include #include int main(void) { // ask user for number printf("How many bottles will there be? "); int n = GetInt(); // exit upon invalid input if (n < 1) { printf("Sorry, that makes no sense.\n"); return 1; } // sing the annoying song printf("\n"); while (n > 0) { printf("%i bottle(s) of beer on the wall,\n", n); printf("%i bottle(s) of beer,\n", n); printf("Take one down, pass it around,\n"); printf("%i bottle(s) of beer on the wall.\n\n", n - 1); n--; } }