4

CPP Program To Print Floyd's Triangle using For Loop

 2 years ago
source link: https://www.geeksforgeeks.org/videos/cpp-program-to-print-floyds-triangle-5-row-using-for-loop/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
CPP Program To Print Floyd's Triangle using For Loop
CPP Program To Print Floyd's Triangle using For Loop
Video Player is loading.
Loaded: 0%
Remaining Time -6:04
  • 330 Views
  • 04/04/2022

What is Floyd's triangle? A Floyd’s triangle is a triangle with first natural numbers.

In this CPP program, we have printed Floyd's triangle using the for loop. Basically, 2 loops are used here and a number is initialized as 1 and then incremented on every iteration. The outer loop has the condition as the variable 'i' initialized to 0 and then iterate until i<n where n is the number of rows. The inner loop has a variable j initialized as 0 and iterates it until the condition j<=i. Then you have to print the variable number for each iteration like number++ and at the same time, it would e incremented.

Related article: https://www.geeksforgeeks.org/c-program-print-floyds-triangle/

Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK