Floyd’s Triangle.
The Floyd’s Triangle
is Triangle of number which look like as follows:
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
16 17 18 19 20 21
This
is Floyd’s Triangle of 6 rows. Let us understand C++ program to print above
triangle.
#include<iostream>
using namespace std;
int main()
{
int i,n,c,a=1;
cout<<"Enter the number of rows of Floyd's triangle
to print:";
cin>>n;
for(i=1; i<n; i++)
{
for(c=1;c<i;c++)
{
cout<<a;
a=a+1;
}
cout<<endl;
}
return 0;
}
This is a simple C++ program to print a Floyd’s Triangle
Input && Output:
0 Comments