Oct 5, 2015 at 12:49pm UTC
You have not declared a variable called "extNumber", but you are trying to assign to it on lines 18 and 19, and perhaps on line 19 you'd want to assign the result of number2%10
to a different variable?
Oct 5, 2015 at 1:11pm UTC
Can I know how can I do that?
int extNumber?
So sorry and thank you
Oct 5, 2015 at 1:33pm UTC
You are correct on the int extNumber
. I would strongly advise you to listen to mutexe in relation to assigning the result of number2%10
to a different variable.
Oct 5, 2015 at 2:55pm UTC
What is the assignment question? What r u trying to program?
Oct 5, 2015 at 3:19pm UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
#include <iostream>
using namespace std;
int main()
{
int n1, n2;
int d1 = 0, d2 = 0, d3 = 0, d4 = 0;
int e1 = 0, e2 = 0, e3 = 0, e4 = 0;
cout << "Enter two 4 digit integers: " ;
cin >> n1 >> n2;
d1 = n1 % 10;
n1 = n1 / 10;
d2 = n1 % 10;
n1 = n1 / 10;
d3 = n1 % 10;
n1 = n1 / 10;
d4 = n1 % 10;
// First answer
cout << d1 + e1 << ' ' << d2 + e2 << ' ' << d3 + e3 << ' ' << d4 + e4;
}
This is a
very simple start to how you can do it.
You need to extend it by first getting the e1 etc values
Last edited on Oct 5, 2015 at 3:30pm UTC
Oct 5, 2015 at 3:25pm UTC
Oh my god, Kemort thanks so much for the start. I will try out myself now. So grateful otherwise I am pretty much failing my assignment.
Oct 5, 2015 at 3:29pm UTC
OK Cya :)
Hint: when you get to division, integer division can give you 0 for an answer, 2/3 = 0 but (float)(2)/3 = .66 etc
Last edited on Oct 5, 2015 at 3:34pm UTC