counting_loop.c

 Code:

#include <stdio.h>
int main(void) {
    for (int n = 1; n <= 10; n++) {
        printf("%d\n", n);
    }
}
 Another valid solution:

#include <stdio.h>
int main(void) {
    for (int n = 0; n < 10; n++) {
        printf("%d\n", n + 1);
    }
}

Terminal window:

davidrhmiller@ide50:~/workspace/meeting_3_prework $ make counting_loop
clang -ggdb3 -O0 -std=c11 -Wall -Werror -Wshadow    counting_loop.c  -lcs50 -lm -o counting_loop
davidrhmiller@ide50:~/workspace/meeting_3_prework $ ./counting_loop
1
2
3
4
5
6
7
8
9
10
Comments