Floyd’s Triangle in C

A simple C program to print floyd’s triangle. A user enters the number of rows as seen in the output. 

#include<stdio.h>
#include<conio.h>

void main()
{
int i,j,num=1,n;
clrscr();

printf(“enter the number of rows”);   // how many rows to print.
scanf(“%d”,&n);

for(i=1;i<n;i++)
{
for(j=1;j<=i;j++)
{
printf(“%d”,num);
num++;
}
printf(“\n”);
}
getch();
}

Output:

Leave a Reply