C Program to accept a number and print in Reverse order

#include<stdio.h>
#include<conio.h>
int rev(int);
main( )
{
int a,b,n;
clrscr( );
printf("\n Enter a number:");
scanf("%d",&n);
a=rev(n);
printf("\n REVERSE OF A GIVEN NUMBER IS %d",a);
getch( );
}
int rev( int n)
{
int r,rev=0,s;
while(n>0)
{
r=n%10;
rev=rev*10+r;
n=n/10;
}
return rev;
}

Output:

No comments:

Post a Comment

100 C Programs with Code and Output

Program 1: C Program To Read Two Numbers And Print The Sum Of Given Two Numbers. Program 2: C Program To Read Three Numbers And Prin...