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?
1 ответ
+ 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;