9th tutorial for right angle triangle patterns



This is another pattern for right angle triangle using numbers. This pattern is reverse from the pattern in last tutorial.




The pattern starts from 5 and ends with 12345, means numbers are to be print in reverse order.



To print number in reverse order, we have to do changes in the loop conditions.



As you can see in program the outer loop i.e. i loop is decremented as 12345 is to be printed in last line and then by decrementation 5 is printed in first line.
for(i=k;i>=1;i--)

Thus how loop is changed. i is initialised from the number you have entered as the value of line (here it is 5), the loop will execute till it is equal or greater than 1.

Here printf statement remains same as of last tutorial (pattern n1).


{ 0 comments ... read them below or add one }

Post a Comment