C Program to Reverse a given number

Write a C program reverse a given number.

In this program reverses a number entered by a user and then print it. For example, if a user will enter 6577756 as input then 6577756 will be printed as output.
This C program accepts an integer and reverse it.

c program to reverse a number

Working:-

Step 1. Take the number which you have to reverse as the input variable says number.

Step 2. Obtain its quotient and remainder.

Step 3. Multiply the separate variable with 10 and add the obtained remainder to it.

Step 4. Do step 2 again for the quotient and step 3 for the remainder obtained in step 4.

Step 5, Repeat the process until the quotient becomes zero.

Step 6.When it becomes zero, print the output and exit

Step 7. Stop.

Reverse-a-given-number in c

C program:-

#include<stdio.h>
int main()
{
//Initialization of variables where rev='reverse=0'
int number, rev = 0,store, left;

//input a numbers for user
printf("Enter the number\n");
scanf("%d", &number);

store= number;

//use this loop for check true condition
while (number > 0)
{
//left is for remider are left
left= number%10;

//for reverse of no.
rev = rev * 10 + left;

//number /= 10;
number=number/10;

}
//To show the user value
printf("Given number = %d\n",store);

//after reverse show numbers
printf("Its reverse is = %d\n", rev);

return 0;
}

Output:-

Enter the number 123456
Given number = 123456
Its reverse is =654321