Print the Reverse Number Using For Loop in C Programming


This program is written in the C programming language and is used to print the numbers from the given limit to 1. The program starts by including the standard input/output library (stdio.h) and then defines a main function. Within the main function, the program declares two variables: "n" and "i". The variable "n" is used to store the value entered by the user, while "i" is a counter variable with a value of 1.

The program then prompts the user to enter a limit using the "printf" function and stores the value in the variable "n" using the "scanf" function. Then, the program uses a "for" loop with the counter variable "n" which is initialized with the value entered by user, The loop continues as long as n is greater than or equal to i. Within the loop, The program uses the "printf" function to print the current value of n on each iteration of the loop, and decrement the value of n by 1 in each iteration.

Finally, the program returns 0 to indicate that the program has completed successfully.

Source Code

#include<stdio.h>
int main()
{
  int n,i=1;
  printf("\nEnter the limit:");
  scanf("%d",&n);
  for(n;n>=i;n--)
  {
    printf("\n%d",n);
  }
  return 0;
}
To download raw file Click Here

Output

Enter the limit : 12
12
11
10
9
8
7
6
5
4
3
2
1

List of Programs


Sample Programs


Switch Case in C


Conditional Operators in C


Goto Statement in C


While Loop Example Programs


Looping Statements in C

For Loop Example Programs


Array Examples in C

One Dimensional Array


Two Dimensional Array in C


String Example Programs in C


Functions Example Programs in C