This pattern is totally reverse from the one we have seen in
the last tutorial. Here pattern starts with maximum number that a user has
entered (here 5) till 11111.
Pattern looks like as follows can be programmed as explain
below.
Here, just we need to change the conditions of for loops as
this pattern is reverse of last tutorial.
As we can seen in the program
for(i=k;i>=1;i--)
loop is decremented as we have to print first ‘11111’ in the
last line.
Then inner loop is also reversed that is it is decremented
as
for(j=k;j>=i;j--)
This loop will print numbers in reverse order from 5 to 1 (in our case), maximum number of line
can be changed according to the user.
{ 0 comments ... read them below or add one }
Post a Comment