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. :)

 
Loading...
TOP