C Program – Reverse of a number

By | 2017-08-27T17:47:50+00:00 August 27th, 2017|c-program|0 Comments

C program to reverse of a number.

Reverse of a number :


#include<stdio.h> 
int reverse(int n); 
int main(void) 
{ 
    int num; 
    printf("Enter any number to reverse : "); 
    scanf("%d",&num); 
    printf("Reverse of given number : %d\n",reverse(num));     
    return 0; 
} 
int reverse(int n) 
{ 
    int rev=0; 
    do 
    { 
        rev=rev*10+n%10; 
        n/=10; 
    }while(n>0); 
    return rev; 
}

[box type=”success” align=”alignleft” class=”” width=”100%”]

Enter any number to reverse : 45623
Reverse of given number : 32654

[/box]

Happy Learning 🙂

About the Author:

Hi Folks, you have reach this so far, that shows you like what you are learning. Then why don't you support us to improve for bettor tutorials by leaving your valuable comments and why not you keep in touch with us for latest updates on your favorite blog @ facebook , twitter , Or Google+ ,

Leave A Comment