c_winter_2019/sheldon.c
2020-01-31 14:49:37 +01:00

32 lines
678 B
C

#include <stdio.h>
int main(void) {
int n_knocks;
printf("how many knocks?\n");
scanf("%d", &n_knocks);
for (int i = 0; i < n_knocks; ++i) {
printf("Knock, knock, knock - Penny?\n");
}
int n_actual_knocks;
printf("and how many actual knocks?\n");
scanf("%d", &n_actual_knocks);
for (int i = 0; i < n_knocks; ++i) {
for (int j = 0; j < n_actual_knocks; ++j) {
if (j == 0) {
printf("Knock");
} else {
printf(", knock");
}
}
if (n_actual_knocks != 0) {
printf(" - ");
}
printf("Penny.\n");
}
return 0;
}