Print reverse of a number using while loop - C

C program to read a number and find reverse of that number.

Solution:

#include<stdio.h>
int main()
{
      int r=0,l;
      long n;
      printf("Enter Number : ");
      scanf("%ld",&n);
      while(n>0)
      {
            l=n%10;
            r=r*10+l;
            n=n/10;
      }
      printf("\nReverse Number : %d",r);
      return 0;
}


Output:

reverse number