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.
This commit is contained in:
Cody Boone Ferguson committed 2023-05-21 09:09:54 -07:00
1 parent 1b9ea65e05
commit 93684cfc19
4 files changed
+64 -2

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
#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;
}