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 Odpowiedź
+ 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