Friday, 4 December 2015

Reverse an integer number with while loop

This code is using for revese an integer number.

Sample Input     : 12345
            Output  : 54321

Code is : 

#include<stdio.h>

int main()
{
    int Num1,b;

    printf("\n\tEnter Number to Reverse : ");
    scanf("%d",&Num1);

    printf("\n\tReverse is : ");
    while(Num1!=0)
    {
        b=Num1%10;
        printf("%d",b);
        Num1=Num1/10;

    }

}

No comments:

Post a Comment