+ 2

What is the correct answer & if there's no outcome then describe why?

what is the output of this code? #include<iostream> using namespace std; int main() { string str =''2''; int l=2; cout<<str+l; }

4th Dec 2017, 6:04 PM
Kumar Amit
Kumar Amit - avatar
9 ответов
+ 4
I dont know if you put it in here right but #include<iosteam> //Needs to be <iostream> using namespace std; int main() { string str ='2' // needs ; at end and will error if you dont use "2" becasue '' is for char and you are making it a string. int l=2; cout<<str+l; //After other things are changed this will give you a compilation error because you cant add a string to a int. }
4th Dec 2017, 6:27 PM
Mooaholic
Mooaholic - avatar
+ 3
it's show compilers error....what is the correct answer and describe the right way also😊
4th Dec 2017, 6:07 PM
Kumar Amit
Kumar Amit - avatar
+ 3
ha ha ha.....here some typing mistake.... but I satisfied your answers😊👍👌
4th Dec 2017, 6:32 PM
Kumar Amit
Kumar Amit - avatar
+ 3
your 3rd comment clear my doubt
4th Dec 2017, 6:32 PM
Kumar Amit
Kumar Amit - avatar
+ 3
ok @kurwius....means that first define then add?
4th Dec 2017, 6:39 PM
Kumar Amit
Kumar Amit - avatar
+ 3
thanks @kurwius now I understand...😊
4th Dec 2017, 6:57 PM
Kumar Amit
Kumar Amit - avatar
0
thanks for help @kurwius
23rd Jan 2018, 2:13 AM
Kumar Amit
Kumar Amit - avatar