In this tutorial, we will write Floyd’s triangle pattern program in C. Before that, you should have knowledge on the following topic in C.
Floyd’s Triangle in C
#include <stdio.h>
void main()
{
int i, j, k = 1, rows;
printf("Enter the no. of rows: ");
scanf("%d", &rows);
printf("Floyd's Triangle:\n");
for (i = 1; i <= rows; i++)
{
for (j = 1; j <= i; j++, k++)
{
printf("%2d ", k);
}
printf("\n");
}
getch();
}
Output:
