Reverse a Integer Number

Here is a C program to reverse a Integer Number:

#include <stdio.h>

int main()
{
    int num, reverse;
    printf("Enter a number to reverse it: ");
    scanf("%d",&num);
    reverse = 0;
    while(num!=0){
        reverse = reverse * 10;
        reverse = reverse + num % 10;
        num = num / 10;
    }
    printf("Reverse is: %d",reverse);
    return 0;
}

0 comments :

Post a Comment

Spam comments will be deleted. :)

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.

 
<>
TOP