C program to find reverse of a number

C program to find reverse of a number: In this program we will use while loop to find reverse of a number before this we already discuss how to reverse a string.

Code for C program to find reverse of a number

#include <stdio.h>
#include <conio.h>
int main()
{
  int n, reverse = 0, remainder;
  printf("Enter an integer: ");
  scanf("%d", &n);
  while (n != 0)
  {
    remainder = n % 10;
    reverse = reverse * 10 + remainder;
    n /= 10;
  }
  printf("Reversed number = %d", reverse);
  return 0;
}

Output

Enter a number: 123
Reversed Number: 321

Read: C program to find the factorial of n numbers


If You Like This Page Then Make Sure To Follow Us on Facebook, G News and Subscribe Our YouTube Channel. We will provide you updates daily.
Shares
facebook sharing button Share
twitter sharing button Tweet
whatsapp sharing button Share
telegram sharing button Share
pinterest sharing button Pin

Leave a Comment