Program to reverse a number in C

#include<stdio.h>
#include<conio.h>

void main()
{
int long a,n,rev=0;
clrscr();
printf(“enter any number”);
scanf(“%lld”,&n);

while(n>0)
{
a=n%10;
rev=rev*10+a;
n=n/10;
}
printf(“%lld”,rev);
getch();
}

Output:

reverse program in C

 

Leave a Reply