0

Whats wrong with my code?

#include <iostream> using namespace std; int main() { int a,b; cin<<"Enter the numbers"; cout<<a+b; return 0; }

18th Aug 2017, 3:22 PM
Darwin
Darwin - avatar
5 Réponses
+ 3
cin is for input, not output
18th Aug 2017, 3:23 PM
Jordan Chapman
Jordan Chapman - avatar
+ 3
cin is an object of iostream and used to flow data between standard input(keyboard) and standard output (monitor ) so u could only user cin for standard input such as input of int,char float single Variable (char array not included for input of cin) so your code should be like this ... int main() { int a,b; cout<<"enter the number 1"<<endl; cin>>a; cout<<"enter the number 2"<<endl; cin>>b; cout<<a+b; return 0; } and remember you cannot use quotation ("") symbol in cin ...it is so basics of c++ or any other languages..... hope it will help you ....
18th Aug 2017, 3:38 PM
SatanicAngal666
SatanicAngal666 - avatar
+ 1
in and out vice versa, so >> and << vice versa.
14th Nov 2017, 1:37 PM
shouta yui
0
yea,I asked the user for the input ..then printed to add it ...then why?
18th Aug 2017, 3:24 PM
Darwin
Darwin - avatar
0
thank u bro
18th Aug 2017, 3:52 PM
Darwin
Darwin - avatar