Answers for "Print Floyd's Triangle"

C++
0

Print Floyd's Triangle

#include <iostream>
using namespace std;

int main()
{
    int rows, number = 1;

    cout << "Enter number of rows: ";
    cin >> rows;

    for(int i = 1; i <= rows; i++)
    {
        for(int j = 1; j <= i; ++j)
        {
            cout << number << " ";
            ++number;
        }

        cout << endl;
    }

    return 0;
}
Posted by: Guest on June-05-2021

Browse Popular Code Answers by Language