Pattern Programs (54321 5432 543 54 5)

Pattern programs are programs which give a output with some pattern consist of numbers,letters or stars.
Example pattern outputs are,
Logic for 54321 5432 543 54 5 pattern.

User input - N:
for(i=1; i<=N; i++) 
 {
  for(j=N; j>=i; j--) 
   { 
    print  j value;
   } 
  print new line;
 }
This logic will  prints the pattern of  
5 4 3 2 1
5 4 3 2 
5 4 3
5 4 
5


Check with  online compiler here.

Comments

Post a Comment