Online Snippets Library

Create a Reverse counting program in C

Reverse counting is sequence of numbers in descending order without zero.Step to create reverse counting is given below.

  • Define start and end Point of Counting.
  • Iterate Number from end to start
  • Display values of iteration.
C Program
#include <stdio.h>

int main() {
   int i, start, end;

   start = 1;
   end = 5;

   //reverse counting, we'll interchange loop variables

   for(i = end; i >= start; i--) 
      printf("%2d\n", i);

   return 0;
}

Output

5 4 3 2 1