Tuesday, 24 December 2013

If a five-digit number is input through the keyboard, write a program to reverse the number.(c++ code)

 #include<iostream>
using namespace std;
#include<conio.h>
int main()
 {
 float a,b,c,d,e,t,a2,b2,c2,d2,e2,s;
 int a1,b1,c1,d1,e1;
 cout<<"\nInput a 5 digit number";
 cin>>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;

 cout<<"\nThe required result is "<<s;
 getch();
  return 0;

  /*  Letuswithc:

       this page is designed to help you learn C or C++.
  Understandable C and C++ programming tutorials, compiler reviews, source code, tips and tricks. 
         */
 }

No comments:

Post a Comment