Program to print floyd triangle
Program:
/* Program to print number triangle */
#include"iostream"
using namespace std;
int main()
{
int i, j, k=1, rows;
cout<<"Enter the number of rows: ";
cin>>rows;
for(i=1; i<=rows; i++)
{
for(j=1; j<=i; j++)
{
cout<<k;
k++;
}
cout<<"\n";
}
}
Output:

/* Program to print number triangle */
#include"iostream"
using namespace std;
int main()
{
int i, j, k=1, rows;
cout<<"Enter the number of rows: ";
cin>>rows;
for(i=1; i<=rows; i++)
{
for(j=1; j<=i; j++)
{
cout<<k;
k++;
}
cout<<"\n";
}
}
Output:
Comments
Post a Comment