Thursday, December 2, 2010

C Program For Floyd's Triangle

What is a Floyd's Triangle
It is a pattern of numbers arranging in this format.
Format of numbers like
1
2 3
4 5 6
7 8 9 10


Program Code


//C program to print Floyd’s triangle
#include < stdio.h>
#include < conio.h>
void main()
{
int i , j , r ;
int num=0 ;
clrscr();
printf(“How many rows you want in the triangle:”);
scanf(“%d”,&r);
for(i=1;i<=r;i++)
{
for(j=1;j<=i;j++)
{
printf(“\t%d”,++num);
}
printf(“\n”);
}
getch();
}

Input/Output


floyd triangle

5 comments:

Sammy The King said...

I Think Floyd Triangle Should Have this type of output:
1
01
101
0101
10101
Cheers!!

Unknown said...

#include
#include
void main()
{
int i,j;
clrscr();
for(i=1;i<=5;i++)
{
for(j=i;j>=5;j--)
{
if(%2==0)
{
pf("0");
}
else
{
printf("1");
}
}
}
getch();

Unknown said...
This comment has been removed by the author.
Unknown said...
This comment has been removed by the author.
Unknown said...

I want an output like
4
43
432
4321

Post a Comment

Dont SPAM