What's wrong with this code? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

What's wrong with this code?

I wanted to make a simple calculator with to int's but something apparently is wrong with this a+b= sum code help me find the problem please Here's the code #include <iostream> using namespace std; int main() { int a,b; cout << "Type one number \n"; cin >> a; cout << a; cout << "Type 2nd number to sum\n"; cin >> b; sum = a + b; cout << "The result is "<< sum << endl; return 0; }

16th Jun 2017, 8:45 PM
sovietcat
sovietcat - avatar
2 Antworten
+ 14
You just have to put an "int" before "sum". int sum = a + b; // Just the finished program #include <iostream> using namespace std; int main() { int a,b; cout << "Type 1rst number: "; cin >> a; cout << a; cout << "\nType 2nd number: "; cin >> b; cout << b; int sum = a + b; cout << "\n\nThe result is: "<< sum << endl; return 0; }
16th Jun 2017, 8:53 PM
Maz
Maz - avatar
0
oh thanks alot
17th Jun 2017, 6:50 AM
sovietcat
sovietcat - avatar