C / C++ program to print the Floyd's Triangle on Screen

Leave a Comment
/* A floyd's triangle is an right angled triangular array of natural numbers. It is defined by filling the rows of the triangle
with the consecutive numbers,starting with 1 in the top left corner:
The sample of this program is :
1
2  3
4  5  6
7  8  9  10

*/ 

#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,a=1,n;
printf("\nEnter the maximum limit:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<i+1;j++)
{
printf("%d ",a);
a=a+1;
}
printf("\n");
}
getch();
return 0;
}


Screenshot:
C / C++ program to print the Floyd's Triangle on Screen
C / C++ program to print the Floyd's Triangle on Screen

0 comments: