Posts

Showing posts from May, 2020

Program to print 2 3 4 5 6, 4 5 6 7 , 6 7 8 , 8 9 , 10 [Nested for loop]

Image
Output Explanation Here, nested for loops is used. The varriable  i initialize from 1 and then passes through next loop j and it gets continue to execute the statement that is inside the j block until the condition of j loop gets false. In the first loop of j, the value of i is 1 which is equal to the initialization of j and prints  the addition of  i and j  i.e  2.  Next time, the value of j increase to 2 but the value of i remains same as 1 and prints the addition of i and j i.e, 3  and  at last loop of j the value of j reaches to 5 but still the value of i is 1 and prints the addition of i and j,  i.e, 6.  When the condition gets false,  steps goes outside the loop and it meets the statement that prints next line.  Since,  the  condition of   loop   of  first loop of i is not false, the loops  begins  agai.  This  time the value of i is 2 and passes inside th...