Program to print floyd’s triangle in c; Through this tutorial, we will learn how to print floyd’s triangle in c program.
C Program to Print Floyd’s Triangle
#include <stdio.h>
int main()
{
int Rows, i, j, Number = 1;
printf(" Please Enter the Number of Rows: ");
scanf("%d", &Rows);
printf(" \n Printing FLOYD'S Triangle \n \n");
for ( i = 1 ; i <= Rows; i++ )
{
for ( j = 1 ; j <= i; j++ )
{
printf("%d ", Number);
Number++;
}
printf("\n");
}
return 0;
}
The output of the above c program; is as follows:
Please Enter the Number of Rows: 5 Printing FLOYD'S Triangle 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15