What is wrong in this ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is wrong in this ?

#include <iostream> using namespace std; int main() { int a; int b; int p = a + b; cout<<"inter a number"<<cin>>a; cout<<"inter another number"<<cin>>b; cout<<p; return 0; }

4th May 2018, 5:57 PM
Amir Fall
Amir Fall - avatar
2 Answers
+ 3
1) dont add uninitialized numbers (int p=a+b) 2) you cannot use cin with cout object (and opposed)... use cout, then in another expression, use cin 3) Order in you case is wrong... You must get a and b from cin, then add they and last show sum (you sum first, after get they and show last)
4th May 2018, 6:02 PM
KrOW
KrOW - avatar
+ 1
thanks i'll try again
4th May 2018, 6:05 PM
Amir Fall
Amir Fall - avatar