I/O Operations Print Floyd's

QUESTION DESCRIPTION 

Create a logic to print Floyd's triangle upto the given n rows.

Refer Sample Test Cases.

Programming Language need to be used:C++

TEST CASE 1 

INPUT
5
OUTPUT
1
23
456
78910
1112131415

TEST CASE 2 

INPUT
4
OUTPUT
1
23
456
78910





#include <iostream>
using namespace std;

int main()
{
    int n, i,  c, a = 1;
    
     cin >> n;
    
    for (i = 1; i <= n; i++)
    {
        for (c = 1; c <= i; c++)
        {        
            cout << a; 
            a++; 
        }
        cout << endl;
    }    
    return 0;
}

Comments

Popular Posts