In this program we have to display numbers in reverse order from 10 to 0 for that 
 we have used for loop here and as it has three parameters initialization , condition and
 increment/decrement. so, now its easy for us to understand that to make reverse order
 we have initialized the value of variable n as 10 and condition >0 so that as soon as it crosses
 zero it comes out of loop and n-- this is an decrement operator which is used to decrease 
value by 1 every time it checks the condition true it can also be written as n=n-1.

 Program
#include <stdio.h>
#include <conio.h>
 void main()
  {
  int n=10;
  for (n=10;n>=0;n--)
   {
    printf("%d\t",n);
   }
}
Output:





                                                                          << Back

Post a Comment

Previous Post Next Post