Floyd's triangle in C

Floyd's triangle is a right-angled triangle which shows the natural numbers in consecutive order in each every row wise.The height of right-angled triangle is based the number of rows implemented.
floyd-triangle.c
1 #include <stdio.h> 2 int main() { 3 int rowCount, i, j, number = 1; 4 printf("Enter the number of rows: "); 5 scanf("%d", &rowCount); 6 for(i = 1; i <= rowCount; i++) { 7 for (j = 1; j <= i; ++j) { 8 printf("%d ",number); 9 number++; 10 } 11 printf("\n"); 12 } 13 return 0; 14 }

No comments:

Post a Comment