C Program to reverse natural number
Write a c program to reverse natural numbers.
To make this program we need to understand what is natural number and how to reverse a number
What is natural number?
Natural numbers are positive integers starting with 1, 2, 3, etc.
How to reverse a number?
We need to subtract 1 from that number to get the another number and this process is repeated until 1.
Code
#include <stdio.h>
int main()
{
int i, last;
printf("Enter the last natural number: ");
scanf("%d", &last);
for(i=last; i>=1; i--)
{
printf("%d\n", i);
}
return 0;
}
Output
Enter the last natural number: 55 4 3 2 1