Code: Triangular Star Pattern

 Code: Triangular Star Pattern

Send Feedback
Pattern for N = 4
*
**
***
****
Note : There are no spaces between the stars (*).
Input format :
Integer N (Total no. of rows)
Output format :
Pattern in N lines
Constraints
0 <= N <= 50
Sample Input 1:
5
Sample Output 1:
*
**
***
****
*****
Sample Input 2:
6
Sample Output 2:
*
**
***
****
*****
******

#include<iostream>
using namespace std;


int main(){
int n;
cin>>n;
int row=1;
while(n>=row){
int col=1;
while(row>=col){
cout<<"*";
col++;
}
cout<<endl;
row++;
}

/* Read input as specified in the question.
* Print output as specified in the question.
*/
}

Comments

Popular posts from this blog

Code : All connected components

Coding Ninjas