+ 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)

5th Nov 2023, 6:37 PM
Magdalini
Magdalini - avatar
6 ответов
+ 8
Magdalini , we can do it like this: int res1 = 42; cout << "My result is " << res1; // result will be: My result is 42
5th Nov 2023, 8:51 PM
Lothar
Lothar - avatar
+ 5
Magdalini , please show your try.
5th Nov 2023, 6:53 PM
Lothar
Lothar - avatar
+ 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.
9th Nov 2023, 11:46 AM
Lothar
Lothar - avatar
+ 3
Magdalini Solutions :- int r = 69; cout<<"My result is "<<r;
6th Nov 2023, 5:45 AM
Alhaaz
Alhaaz - avatar
+ 1
Lothar for example cout >> "My result is" result; Where result is a variable
5th Nov 2023, 7:08 PM
Magdalini
Magdalini - avatar
+ 1
Lothar this is actually really helpful thank you!
6th Nov 2023, 5:22 AM
Magdalini
Magdalini - avatar