Example
Input
Input N: 10
Output
Natural numbers from 10-1 in reverse: 10, 9, 8, 7, 6, 5, 4, 3, 2, 1
/**
* C program to all natural numbers in reverse from n to 1
*/
#include <stdio.h>
int main()
{
int i, start;
/* Input start range from user */
printf("Enter starting value: ");
scanf("%d", &start);
/*
* Run loop from 'start' to 1 and
* decrement 1 in each iteration
*/
for(i=start; i>=1; i--)
{
printf("%d\n", i);
}
return 0;
}
Program to print natural number in reverse in given range
/**
* C program to all natural numbers in reverse in given range
*/
#include <stdio.h>
int main()
{
int i, start, end;
/* Input start and end limit from user */
printf("Enter starting value: ");
scanf("%d", &start);
printf("Enter end value: ");
scanf("%d", &end);
/*
* Run loop from 'start' to 'end' and
* decrement by 1 in each iteration
*/
for(i=start; i>=end; i--)
{
printf("%d\n", i);
}
return 0;
}
/*
Output :
Enter starting value: 15
Enter end value: 5
15
14
13
12
11
10
9
8
7
6
5
*/