C Programming
Computer Programming

C Program using function to reverse a given number



Write a Program in C using function to reverse a given number

\* C Program using function to reverse a given number *\

# include < stdio.h >
# include < conio.h >
int   reverse(int) ;

int   main( )
{

int n, rev = 0 ;
printf(" Enter a integer number : ") ;
scanf("%d", &n) ;
rev = reverse(n) ;
printf("\n Reverse of entered numner is : %d ", rev) ;
return (0) ;

}

int   reverse(int n)
{

int rev = 0, t = 0 ;
while( n > 0 )
{
    t = n % 10 ;
    rev = rev * 10 + t ;
    n = n / 10 ;
}
return (rev) ;

}

Output of Program :

Output of C Program using function to reverse a given number