C Program to reverse the given number

#include<stdio.h>
int main()
{
  int n;
  printf("Enter a number\n");
  scanf("%d",&n);
  int reversed_number=0,rem;
  while(n!=0)
  {
    rem=n%10;
    reversed_number=reversed_number*10+rem;
    n=n/10;

  }
  printf("The reversed number is:%d",reversed_number);
}

Output:

C Program to reverse the given number


Comments