What's the problem in this code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What's the problem in this code?

#include <iostream> using namespace std; int main() { int a, b; int sum = a + b; cout << "Enter a number \n"; cin >> a; cout << "Enter another number \n"; cin >> b; cout << sum; return 0; }

19th Feb 2020, 4:58 AM
Manas Negi
Manas Negi - avatar
2 Answers
+ 3
You just need to move “int sum = a + b;” after your final cin. You have to specify what A & B are before you can add them https://code.sololearn.com/cEOGvea73Vqc/?ref=app
19th Feb 2020, 5:00 AM
Jax
Jax - avatar
+ 1
Thanks Jax
19th Feb 2020, 5:02 AM
Manas Negi
Manas Negi - avatar