cout variables difference from c language | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

cout variables difference from c language

When I've learnt C in uni, we always used printf("sum equals to &var"); and refer to the variables in memory with &, like a pointer. My question is, is there any way to use string and variables in the same "cout"? for example: cout << "Answer is &var"; or its always two separate?

13th Jun 2017, 12:57 PM
Who did this?
Who did this? - avatar
1 Answer
+ 3
int a=10, b=20; int c = a+b; In C we write printf ("Sum = %d\n",c); whereas in C++, it is written as cout <<"Sum = " <<c<<endl;
13th Jun 2017, 1:13 PM
เคฆเฅ‡เคตเฅ‡เค‚เคฆเฅเคฐ เคฎเคนเคพเคœเคจ (Devender)
เคฆเฅ‡เคตเฅ‡เค‚เคฆเฅเคฐ เคฎเคนเคพเคœเคจ (Devender) - avatar