Answer to Question #276335 in C++ for Roe

Question #276335

Write C++ that




(1)Convert the inputted 3-digit integer, the single digit to a hundred digit, and the hundreds digit to a single digit, and generate a new inverted number from the converted 3 digits.



(2) Arbitrary 3-digit integers are input by keyboard.



(3) When outputting the result, the required form is: original number: converted number.


4)run test the code in main

1
Expert's answer
2021-12-06T19:21:49-0500
#include <iostream>
#include<cmath>
using namespace std;


int main(){
int n,b,c,a;


cout<<"Enter   3 digit number"<<endl;
cin>>n;
a=trunc(n/100);
b=n-a;
b=trunc(b/10)-a*10;
c=n-(100*a)-(10*b);
cout<<a<<endl;
cout<<b<<endl;
cout<<c<<endl;
int number=c*100+b*10+a;
cout<<"Old number="<<n<<endl;
cout<<"New inverted number="<<number<<endl;
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment