Create a free account on Computer Sir Ki Class and unlock access to valuable learning resources.
Exam Paper Downloads: After registering and logging in, you can download exam question papers in PDF format to practice and prepare for your exams.
Student Support: Get assistance with your doubts, queries, and questions related to your studies. Our support is here to help you understand topics and resolve your learning difficulties.
Register today and make your exam preparation easier and more effective!
Write a C++ code to display the following text using the same cout chain.
Apples = 5 Kg
Bananas = 2 Doz
Oranges = 2.5 Kg
Solution
TC++ #3060
Run Output
Apples = 5 Kg
Bananas = 2 Doz
Oranges = 2.5 Kg
cout<<“Apples = 5 Kg “<<endl <<“Bananas = 2 Doz “<<endl << “Oranges = 2.5 Kg “<<endl;
endl can be used in between multiple portions of the cout chain to change the line.
Notes
One can alternative write following code with three cout statements, but 1 cout chain can make it more efficient. cout<<“Apples = 5 Kg “<<endl; cout<<“Bananas = 2 Doz “<<endl; cout<< “Oranges = 2.5 Kg “<<endl;