Skip to content

Commit c466679

Browse files
author
Sonny Li
committed
Week 2
1 parent ff92c1c commit c466679

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

.DS_Store

0 Bytes
Binary file not shown.

Programs/adding.c

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <stdio.h>
2+
3+
int main() {
4+
5+
int num, total = 0;
6+
7+
printf("Number: ");
8+
scanf("%d", &num);
9+
10+
printf("\n");
11+
12+
for (int x = 1; x <= num; x++)
13+
{
14+
15+
printf("%d ", x);
16+
17+
total = total + x;
18+
19+
}
20+
21+
printf("\n");
22+
printf("The sum is %d.\n", total);
23+
24+
return 0;
25+
26+
}

Projects/.DS_Store

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)