0

Why this code isn't working? (C++)

Code: #include <iostream> using namespace std; int main() { int a; cout << "enter a number"; cin >> a; cout <<" " << a << endl; int b; cout << "enter anther number"; cin >> b; cout << " " << b << endl; int c=a + b; int d=a - b; int e=a * b; cout<< "The sum is "<<c, d, e; return 0; } This is is a calculator the problem is that the multiplication isn't working i dont know what Help please

20th Jul 2017, 5:42 PM
Cout
Cout - avatar
8 Answers
+ 2
last cout is done wrong. It should be cout<< "The sum is " << c << " "<< d << " " << e; The compiler cuts everything after comma, in newer compilers it shows error.
20th Jul 2017, 5:44 PM
Jakub Stasiak
Jakub Stasiak - avatar
+ 1
@R4Z7 now you see the difference between your code and @Mara's one? I will point the differences: -Variables are initialized -Last cout has changed to the one that I told you about.
20th Jul 2017, 6:35 PM
Jakub Stasiak
Jakub Stasiak - avatar
0
What is it c++11?
20th Jul 2017, 6:35 PM
Cout
Cout - avatar
0
Still she did it different you just told me to change the last line
20th Jul 2017, 6:38 PM
Cout
Cout - avatar
- 1
No you did it wrong your code working but he is printing all of them not just one my code is working just the multiplication isn't it shows no error when i compiler
20th Jul 2017, 5:52 PM
Cout
Cout - avatar
- 1
Ooo
20th Jul 2017, 6:46 PM
Cout
Cout - avatar