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>
2int 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}
Output
Enter the number of rows: 5 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15