I can\'t figure out the error in this programme, can you help my the prompt is W
ID: 672689 • Letter: I
Question
I can't figure out the error in this programme, can you help my
the prompt is
Write a C++ program to enter an integer number of 4 digits and print it out in an inverse order.
And my code
#include<iostream>
using namespace std;
int main()
{int num,a,b,c,d,newnum;
cout<<" Enter Your Number:"<<endl;
cin>>num;
a=num%10;
num=num/10;
b=num%10;
num=num/10;
c=num%10;
num=num/10;
d=num%10;
newnum=(a*1000)+(b*100)+(c*10)+(d*1)
cout<<" Your Number Is:"<<newnum;
return 0;}
Explanation / Answer
#include<iostream>
using namespace std;
int main()
{int num,a,b,c,d,newnum;
cout<<" Enter Your Number:"<<endl;
cin>>num;
a=num%10;
num=num/10;
b=num%10;
num=num/10;
c=num%10;
num=num/10;
d=num%10;
newnum=(a*1000)+(b*100)+(c*10)+(d*1);
cout<<" Your Number Is:"<<newnum;
return 0;}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.