Write a C program to enter any number from user and find reverse of the given number using for loop. How to find reverse of any number in C programming using loops. Logic to find reverse of any number in C program.

**Example**

**Input**

Input number: 1234

**Output**

Reverse of 1234 = 4321

## Required knowledge

## Logic to find reverse

I have divided the logic to find reverse of any number in four simple steps.

- Extract last digit of the given number by performing modulo operation.
- Increase the place value of reverse. For that multiply reverse variable by
`10`

. - Add the last digit computed above, with reverse.
- Remove the last digit by dividing the number by
`10`

. As it is not needed anymore.

Let us implement the logic in a C program.

## Program to find reverse of any number

```
/**
* C program to find reverse of any number
*/
#include <stdio.h>
int main()
{
int num, reverse = 0;
/* Input the number from user */
printf("Enter any number to find reverse: ");
scanf("%d", &num);
/* Repeat the till num becomes 0 */
while(num != 0)
{
/* Multiple rev by 10 and adds the last digit to it*/
reverse = (reverse * 10) + (num % 10);
/* Remove last digit from num */
num = num / 10;
}
printf("Reverse = %d", reverse);
return 0;
}
```

Take your skills to next level. Learn this program using recursive approach.

Read more - Program to find reverse of any number using recursion.

Output

Enter any number to find reverse: 1234 Reverse = 4321

Happy coding 😉

### Recommended posts

- Loop programming exercises index.
- C program to count number of digits in any number.
- C program to find sum of first and last digit of any number.
- C program to swap first and last digit of any number.
- C program to print multiplication table of any number.
- C program to find frequency of each digit in given number.
- C program to print number in words.

<pre><code> ----Your Source Code---- </code></pre>