Techie Programmer

Understanding Floyd's Triangle in C: Print Number Sequences with Ease

Floyd's Triangle is a right-angled triangular arrangement of numbers, where the numbers are arranged sequentially in rows. The first row contains one number, the second row contains two numbers, the third row contains three numbers, and so on.

You can get the complete code from Github

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 }