If a five-digit number is input through the keyboard, write a program to reverse the number.
void main()
{
float a,b,c,d,e,t,a2,b2,c2,d2,e2,s;
int a1,b1,c1,d1,e1;
printf("\nInput a 5 digit number");
scanf("%f",&t);
a=t/10000.0;
a1=a;
b=(t-(a1*10000.0))/1000;
b1=b;
c=(t-(a1*10000.0)-(b1*1000))/100;
c1=c;
d=(t-(a1*10000.0)-(b1*1000)-(c1*100))/10;
d1=d;
e=t-(a1*10000.0)-(b1*1000)-(c1*100)-(d1*10);
e1=e;
a2=e1*10000.0;
b2=d1*1000.0;
c2=c1*100.0;
d2=b1*10.0;
e2=a1*1.0;
s=a2+b2+c2+d2+e2;
printf("\nThe required result is %f",s);
}
Subscribe to:
Post Comments (Atom)
#include
ReplyDelete#include
void main()
{
long int no,reverse=0;
int digit;
scanf("%ld",no);
for( ;no>0; )
{
digit=no%10;
reverse=reverse*10 + digit; no=no/10;
}
printf("%ld",reverse);
getch();
}