Thread Closed

The following C++ program does not compile

 
Share Thread Thread Tools
Sep14-08, 10:34 PM   #1
 

The following C++ program does not compile


cout << "2 + 3 * 5 = " 2+3*5 << endl;


do I just need to put it as

cout << "2 + 3 * 5=" << (2+3*5) << endl;
PhysOrg.com
PhysOrg
science news on PhysOrg.com

>> Ants and carnivorous plants conspire for mutualistic feeding
>> Forecast for Titan: Wild weather could be ahead
>> Researchers stitch defects into the world's thinnest semiconductor
Sep14-08, 10:52 PM   #2
 
Blog Entries: 14
Quote by soul5 View Post
cout << "2 + 3 * 5 = " 2+3*5 << endl;


do I just need to put it as

cout << "2 + 3 * 5=" << (2+3*5) << endl;
First one is bad, second one looks good.

Why don't you simply compile the second, run and test it? ooO, does the second one also throws error?
Sep14-08, 11:32 PM   #3
 
Recognitions:
Homework Helper Homework Help
I'm pretty sure you can't mix string output together with variables. You must separate them into with <<.
Thread Closed
Thread Tools


Similar Threads for: The following C++ program does not compile
Thread Forum Replies
JAVA: Why won't it compile? Programming & Comp Sci 3
Java compile problems Programming & Comp Sci 2
Java program won't compile.. Engineering, Comp Sci, & Technology Homework 2
compile open office on mac Computing & Technology 1
Help me compile a physics software list General Discussion 16