Friday, August 29, 2014

If a five-digit number is input through the keyboard, write a program to print the digits of that number in reverse order. For example if the number that is input is 54321 then the output should be displayed as 12345


Code

#include<stdio.h>
int main()
{
int a,sum,r1,r2,r3,r4,a1,a2,a3,a4;

printf ("Enter five digit number: ");
scanf ("%d",&a);

r1 = a/10000;
a1 = a%10000;

r2 = a1/1000;
a2 = a1%1000;

r3 = a2/100;
a3 = a2%100;

r4 = a3/10;
a4 = a3%10;

printf ("\nReverse Order = %d%d%d%d%d",a4,r4,r3,r2,r1);

printf ("\n\nPress any key to close.");

getch ();
return 0;
}

Output

reverse number c language

No comments :

Post a Comment

Note: Only a member of this blog may post a comment.

Copyright 2017. All Rights Reserved. Privacy Policy / Terms And Conditions / Sitemap / Contact