+ 1
Can I put a string in "" and a variable by using cout << at the same time, or it should be separated?
C++ question (easy)
6 Answers
+ 8
Magdalini ,
we can do it like this:
int res1 = 42;
cout << "My result is " << res1; // result will be: My result is 42
+ 5
Magdalini ,
please show your try.
+ 4
Enhee Eegii ,
please do not use an exising post (from someone else) to publish a new question inside the current one. please start a new question.
+ 3
Magdalini
Solutions :-
int r = 69;
cout<<"My result is "<<r;
+ 1
Lothar for example
cout >> "My result is" result;
Where result is a variable
+ 1
Lothar this is actually really helpful thank you!