Files
Cody Boone Ferguson 93684cfc19 Add another program for 2001/anonymous
This sings a different counting song, Ten in the Bed. It uses another C
feature (a char *[]) that the Ten Green Bottles does not use. This is
for fun as well as to show another program (with a different C feature)
that the program works on, again assuming -m32 is allowed.

Instead of using numbers it uses strings (as expected with a char *[])
in the singing.

This was for fun (and to see if the program would work on arrays) after
I remembered the song in a comment on GitHub - about the Ten Green
Bottles song.
2023-05-21 09:09:54 -07:00

24 lines
504 B
C

#include <stdio.h>
char *bed[] = { "TEN", "NINE", "EIGHT", "SEVEN", "SIX", "FIVE", "FOUR", "THREE", "TWO", "ONE" };
void sing(int persons) {
printf("There %s %s in the bed and the little one said, '%s'\n",
persons==9?"was":"were",
bed[persons],persons==9?"Good night!":"Roll over, roll over!");
if (persons != 9)
printf("So they all rolled over and one fell out...\n");
}
int main() {
int persons = 0;
while(persons<10) {
sing(persons++);
puts("");
}
return 0;
}