Skip to content

Commit ad013ab

Browse files
committed
triangular table
1 parent 46c4092 commit ad013ab

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

prog.5.3.c

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Program to generate a table of triangular numbers
2+
3+
#include <stdio.h>
4+
5+
int main (void)
6+
{
7+
int n, triangularNumber;
8+
9+
printf ("TABLE OF TRIANGULAR NUMBERS\n\n");
10+
printf (" n Sum from 1 to n\n");
11+
printf ("--- ---------------\n");
12+
13+
triangularNumber = 0;
14+
15+
for ( n = 1; n <= 10; ++n ) {
16+
triangularNumber += n;
17+
printf (" %i %i\n", n, triangularNumber);
18+
}
19+
20+
return 0;
21+
}

0 commit comments

Comments
 (0)