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
//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();
}
![floyd triangle](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZPMDkT-cD4bTqq-N2p5Sz1coMLvG4G-mI1DtqJRaOGT94itLs7z2WYiWaGUTDp3R6Qi8tx9GBDtC2JI5wontYpautnGCdWzzBnoltjie_Ey9Qcdl3mxlqhpD4qa8U7-yJwVUcbyObqct_/s400/floyd.JPG)
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();
}
No comments:
Post a Comment