A five-digit number is entered through the keyboard. Write a program to obtain the reversed number and to determine whether the original and reversed numbers are equal or not.
void main()
{
float number,a,b,c,d,e,a2,b2,c2,d2,e2,t;
int a1,b1,c1,d1,e1;
printf("\nInput a 5 digit number");
scanf("%f",&number);
a=number/10000;
a1=a;
b=(number-(10000.0*a1))/1000;
b1=b;
c=(number-(10000.0*a1)-(1000*b1))/100;
c1=c;
d=(number-(10000.0*a1)-(1000*b1)-(100*c1))/10;
d1=d;
e=(number-(10000.0*a1)-(1000*b1)-(100*c1)-(10*d1));
e1=e;
a2=e1*10000.0;
b2=d1*1000.0;
c2=c1*100.0;
d2=b1*10.0;
e2=a1*1.0;
t=a2+b2+c2+d2+e2;
printf("\nThe reversed number is %f",t);
if(t!=number)
printf("\nThe original number and reversed number are not equal");
}
Subscribe to:
Post Comments (Atom)
/*A five-digit number is entered through the keyboard.
ReplyDeleteWrite a program to obtain the reversed number
and to determine whether the original and reversed numbers are equal or not.*/
//author::mudasir yaqoob....
#include
#include
int main(void)
{
long temp=0,t=0,num,sum=0;
int i;
printf("Enter the five digit number: \n\n\n");
scanf("%ld",&num);
sum=num;
while(num!=0)
{
t=num%10;
temp=temp*10+t;
num=num/10;
}
printf("Reverse of the number is :\n\n\n");
printf("%ld\n\n",temp);
if(sum==temp)
{
printf("No is pallindrome\n\n\n");
}
else
{
printf("NO is different");
}
getch();
}
#include
ReplyDeletevoid main()
{
int num,a,b,c,d,e,rev_num;
printf("Input the 5 digit number: ");
scanf("%d", &num);
a=num%10;
b=(num/10)%10;
c=((num/10)/10)%10;
d=(((num/10)/10)/10)%10;
e=((((num/10)/10)/10)/10)%10;
rev_num=(((((a*10000)+b*1000)+c*100)+d*10)+e);
printf("The reversed number is %d\n", rev_num);
if(num==rev_num)
printf("The original and the reversed numbers are equal\n");
else
printf("The original and the reversed numbers are not equal\n");
}
thank you. You people done a great work...
ReplyDelete#include
ReplyDeleteint main ( )
{ int a,b,c;
int d=0;
printf ("enter 5 digit number");
scanf ("%d/n",&a);
for (b=5;b!=0;b--)
{ c=a%10;
a=a/10;
d=d*10+c;
}
printf ("%d",d);
return 0;
}