Write a function in C++ to print the Floyd's Triangle.
#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;
}
Comments
Leave a comment