Presentation is loading. Please wait.

Presentation is loading. Please wait.

Print the following triangle, using nested loops

Similar presentations


Presentation on theme: "Print the following triangle, using nested loops"— Presentation transcript:

1 Print the following triangle, using nested loops. 1 2 1 2 3 2 3 4
Problem Print the following triangle, using nested loops. 1 2

2 Algorithm Dry Run i=1 Step 1:- run the for loop from 1 to 5 with i as iterating value i=2 i=3 i=4 i=5 j=1 j=1,2 j=1,2,3 j=1,2,3,4 j=1,2,3,4,5 Step 2:- run second for loop with j from 1 to i Step 3:- print the value of j 1 1 2 1,2,3 1,2,3,4 1,2,3,4,5 Step 4:- print next line \n \n \n \n \n

3 Task 19 Print using nested for loops 1 1 2 Task 20 Print using nested for loops 1 2 2 Group work Print using nested for loops * * * * * * * * * * * * * * * * * * * * * * * * *


Download ppt "Print the following triangle, using nested loops"

Similar presentations


Ads by Google