Upright right half triangle of numbers – CSKC
Sign In

Search

Code Learning #CPP#2809    siteicon   siteicon  

Upright right half triangle of numbers

Print the right half upright pyramid of increasing numbers.

Learning Objectives

  • Learning to print half triangle of increasing numbers series.

Source Code

TC++ #2809

 

Source Code

×

Ask AI About This Code

Default Prompt that is passed along with the code is given below, You can write your own prompt if you so desire.



×

Test CPP

  Related ( ? ) :

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<<j<<” “; //The inner loop count is printed, first it will be 1, then 1 2, then 1 2 3 and so on
cout<<“n”; //Next line after inner loop
}
}

Notes

  • Replacing j of the inner loop with any character prints the character pattern.

Common Errors

  • Some time student forget to change the newline outside inner loop and inside outer loop, or some time they do it inner loop. Experiment yourself and understand the error.


Suggested Filename(s): pat-rht-num.cpp,prht-num.cpp



Share

Created: 19-Jan-2018 23:32 | Updated: 19-Jan-2018 23:40|