11th tutorial for right angle triangle patterns



This is another pattern for right angle triangle using numbers. This pattern is totally reverse of the last tutorial’s pattern.




The pattern looks like can be made in program




Now here as we have to reverse the order of numbers to be printed so we have to change the conditions of inner loop, also here we have to print numbers starting from 5 to 54321.



So here we need to change conditions of both for loops i.e. i and j loops. As pattern is reverse from pattern shown in first program of numbers i.e. 8th tutorial both loops are decremented here to reverse the direction of loop.
for(i=k;i>=1;i--)

for(j=k;i>=i;j--)

As we can see both loops are changed. outer loop will be start from maximum number of line entered and executes till it is equal to or greater than 1.

And inner loop will also be started with maximum number of line till the i loop is set.

Here also printf statement will remains unchanged.


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

Post a Comment