hello guys! wanna try a new problem๐๐,
here it goes,
now i'm uploading the solution for it using C++ language.
I have written below solution using Microsoft Visual Studio 2017 version,it may be little bit vary on ios, adios!๐๐
#include<iostream>
using namespace std;
void triangle(int n)
{
if (n == 1)
{
cout << "*"<<endl;
}
else {
triangle(n - 1);
for (int i = 0; i < n; i++)
{
cout << "*";
}
cout << endl;
}
}
int main()
{
int n;
cout << "Enter the n:";
cin >> n;
for (int i = 0; i < n; i++)
{
for (int j = n; j > i; j--)
{
cout << "*";
}
cout << endl;
}
triangle(n);
return 0;
}
Comments
Post a Comment