Upright right half triangle of alphabets (row-wise increasing)
Print the right half upright pyramid of row wise increasing alphabets like follows –
A
B B
C C C
…………..
Learning Objectives
- Printing upright right half triangle of row wise increasing series of alphabets and same alphabet in each column.
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 (i+64)<<” “;
The outer loop count is printed after adding 64 and converted to character type, first it will be A, then B B, then C C C and so on. Since we are printing the outer loop count in this case so every row gives the same symbol.
cout<<“n”; //Next line after inner loop
}
}
Suggested Filename(s): pat-rht-alprw.cpp,prht-arw.cpp
Created: 20-Jan-2018 19:12 | Updated: 20-Jan-2018 19:12|
