Tuesday, 26 January 2016

Cpp Program to print Floyds triangle

This is a Cpp program which prints the Floyd's triangle with respect to the input given.

Floyds triangle


Download Code

PROGRAM :

#include <iostream>

using namespace std;

int main()
{
    int i, j, k = 1,n;
    cout << "Enter the range: ";
    cin >> n;
    cout << "\nFLOYD'S TRIANGLE : \n";
    for (i = 1; i <= n; i++)
    {
        for (j = 1; j <= i; j++, k++)
        {
            cout << "\t" << k;
        }
        cout << "\n" ;
    }
    return 0;
}

OUTPUT :

Cpp Program - Floyds Triangle