How to get reverse of a number

CODE




How to get reverse of a number
If a five digit number is input through the keyboard , write a program to reverse the number
int main()
{
    int num,rev,r1,r2,r3,r4;
    printf("\n enter a 5 digit number:");
    scanf("\n %d",&num);                                                 
    r1=num%10;
    num=num/10;
    r2=num%10;
    num=num/10;
    r3=num%10;
    num=num/10;
    r4=num%10;
    num=num/10;
    rev=r1*10000+r2*1000+r3*100+r4*10+num;
    printf("\n reverse=%d",rev);
}


Output:
enter a 5 digit number:
12345

 reverse=54321

How to get reverse of a number How to get reverse of a number Reviewed by Unknown on December 14, 2018 Rating: 5

No comments:

If you have any doubt or query ,comment below:

Programming copyright © 2018-19. Powered by Blogger.