Upright right half triangle of alphabets (column-wise increasing)
Print the right half upright pyramid of column wise increasing alphabets like follows –
A
A B
A B C
Learning Objectives
- Printing upright right half triangle of increasing series of alphabets.
Source Code
|
|
Related ( ? ) : |
Run Output
Code Understanding
int cnt; cout<<“Give row count : “; cin>>cnt; //Row count collected from user
for(int i=1;i<=cnt;i++) //Outer loop for row count
{
for(int j=1;j<=i;j++) //Inner Loop for column count, Column keep increasing with each iteration
cout<<char (j+64)<<” “; //The inner loop count is printed after adding 64 and converted to character type, first it will be A, then A B, then A B C and so on
cout<<“n”; //Next line after inner loop
}
}
Suggested Filename(s): pat-rht-alpha.cpp,prht-alp.cpp
Created: 19-Jan-2018 23:55 | Updated: 29-Jan-2018 19:36|
