Code: Alpha Pattern...

 Code: Alpha Pattern

Send Feedback
Pattern for N = 3
 A
 BB
 CCC
Input format :
Integer N (Total no. of rows)
Output format :
Pattern in N lines
Constraints
0 <= N <= 26
Sample Input 1:
7
Sample Output 1:
A
BB
CCC
DDDD
EEEEE
FFFFFF
GGGGGGG
Sample Input 2:
6
Sample Output 2:
A
BB
CCC
DDDD
EEEEE
FFFFFF

#include<iostream>
using namespace std;


int main(){
int row=1;
int n;
cin>>n;
char ch='A';
while(n>=row){
int col=1;
// char ch='A'+row-1; // it is also carrect
while(row>=col){
cout<<ch;
col++;
}
cout<<endl;
row++;
ch++;
}
/* 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