Question #247117

Write a function in C++ to print the Floyd's Triangle.


Expert's answer

#include <iostream>
using namespace std;
int main(){
    int lines;
    cout << "Enter number of lines: ";
    cin >> lines;
    for(int i = 1; i <= lines; i++)
    {
        for(int j = 1; j <= i; j++)
        {
            cout << "* ";
        }
        cout << "\n";
    }
    return 0;
}
LATEST TUTORIALS
APPROVED BY CLIENTS