Reverse a given number in C

C Program to reverse a number . In this code, the given digits in the number will be reversed

Source code :

#include<stdio.h>

int main(){

int number = 145; // Change the number to reverse
int reverse = 0;

while (number != 0)
   {
      reverse = reverse * 10;
      reverse = reverse + number%10;
      number  = number/10;
   }
 
printf("Reverse of given number is : %d",  reverse);

return 0;

}

Output :

Reverse of given number is : 541

Output :


                

Comments :