C Program to reverse an integer number

C program to reverse the integer number

    1. #include<stdio.h>
    2. int main()
    3. {
    4.    int n;
    5.    int reverse = 0;
    6.    int rem;
    7.    printf("Enter a number: \n");
    8.    scanf("%d", &n);
    9.    while(n!=0)
    10.              {
    11.               rem = n%10;
    12.               reverse = reverse*10+rem;
    13.               n /= 10;
    14.               }
    15.    printf("Reversed Number: %d\n",reverse);
    16.    return 0;
    17. }

Post a Comment

0 Comments