Printing the Flyod’s Triangle – CSKC
Sign In

Search

Code Learning #CPP#2856    siteicon   siteicon  

Printing the Flyod’s Triangle

Printing the Flyod’s triangle of numbers which are increasing in both row and column wise fashion

Learning Objectives

  • Printing the typical Flyod’s Triangle with the help of nested for loops.

Source Code

TC++ #2856

 

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; //The row count will be collected by the the user
int k=1; //This is the beginning number from where the Flyod’s triangle will start
cout<<“Give row count: “; cin>>cnt; //Here we collect the row count
for(int i=1;i<=cnt;i++) //This outer loop is for row increment
{
for(int j=1;j<=i;j++) //This inner loop is for column increment
{
cout<<k<<” “; //The printed count begins here
k++;                  //In each iteration it is incremented whether it is row or column
}
cout<<endl; //New line after each row, so it is given in the outer loop
}
}

Notes


Suggested Filename(s): flyods-triangle.cpp,flyods.cpp



Share

Created: 20-Jan-2018 19:38 | Updated: 1-Mar-2026 17:10|