Programming with Passion

Make the best out of everything.

Friday 18 March 2016

Floyd's Triangle.

C++ Program to display Floyd's Triangle.


1
2 3
4 5 6
7 8 9 10
#include <iostream>
using namespace std;
int main()
{
    int rows,i,j,k=0;
    cout<<"Enter number of rows: ";
    cin>>rows;
    for(i=1;i<=rows;i++)
    {
        for(j=1;j<=i;++j)
          cout<<k+j<<" ";
        ++k;
        cout<<endl;
    }
    return 0;
}

No comments:

Post a Comment