I am a beginner. This is a program to print a right angled triangle.The height and base should same. for example if input n = 3
then we should get the output as.
*
* *
* * *
I wrote the following code for this:
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
while(i>=1){
cout<<"*";
cout<<" ";
i--;
cout<<i;
}
cout<<"\n";
}
}
but it goes on forever. anything wrong?