please help me... i don't know which line of code did i get wrong... the output is supposed to be:
1
12
123
but what i get is:
1
21
321
...here is my code... i need to use while loop for this. thanks guys.
#include<iostream>
using namespace std;
int triangle(int n);
int _tmain(int argc, _TCHAR* argv[])
{
int n;
cout<<"enter number : ";
cin>>n;
cout<<triangle(n)<<endl;
}
int triangle(int n)
{
if (n < 1)
return 0;
else
{
triangle(n - 1);
while(n > 0)
{
cout<<n;
n--;
}
cout<<endl;
}