Program:
Shown below is a Floyd’s triangle.
1
2 3
4 5 6
7 8 9 10
11 15
….
……
79 91.
Write a program to print this triangle.
source file name: Floydtr.C
void main()
{
int n,le,ln;
clrscr();
printf("Floyd's Triangle output: \n");
n=1;
ln=1;
while(ln<=15)
{
for(le=1;le<=ln;le++)
{
printf(" %d", n);
n++;
}
printf("\n");
ln++;
}
getch();
}
output:
0 Comments
Post a Comment