+ 1
#include <iostream> using namespace std; int main() { int a, b; int sum; cout << "20 \n"; cin >> a; cout << "30 \n"; cin >> b; sum = a + b; cout << "Sum is: " << sum << endl; return 0; }
why the sum is comig wrong how to correct ir
6 Antworten
+ 1
what's that 30 and 20 are u giving inputs or what??in that case there's no need of cin statement right!!so,run the program by removing those values or cin statements..
0
because u declared int sum; without assigning zero to it, you see when u leave it the compiler reads it as binary and miltiplies its value to give u a big number in the end
and idk why that cout is 20 and 30
you always need to assign values to variables so make it
int sum = 0;
0
both answers are wrong cant get the correct answer please run
0
The code works. What's wrong with it?
0
your code is right I thinks problem on user input get 1 input 20 and 2 input 30 then check
0
you should use int sum=0