Triangular Number series using the Flyod’s triangle method – CSKC
Sign In

Search

Solved Problem #CPP#2860    siteicon   siteicon  

Problem Statement - Triangular Number series using the Flyod’s triangle method

Write a program to print a series of triangular numbers starting 1 using the property of a flyod’s triangle where the right most number is a triangular number. Accept the number of terms to be printed from the user. The series output would be 1 3 6 10 15 ……

Solution

TC++ #2860

 
×

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

Alternate (?) :   Related ( ? ) :

int terms; //The terms count will be collected by the the user
int k=1; //
This is the beginning number from where the triangular numbers will start

cout<<“Print how many terms of triangular number(s)? “; cin>>terms;
Here we are collecting the the number of terms to be printed

for(int i=1;i<=terms;i++)
//This outer loop is for terms increment
{
for(int j=1;j<=i;j++) //This inner loop is for incrementing for each column rule as per flyod’s triangle
{
if(j==i) cout<<k<<” “; //The printed count begins here when the last number of triangle is to be printed.
k++;                  //In each iteration it is incremented whether it is row or column
}
}

Notes


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



Share

Created: 20-Jan-2018 20:19 | Updated: 18-Dec-2018 19:01|