Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The following C++ program does not compile

  1. Sep 14, 2008 #1
    cout << "2 + 3 * 5 = " 2+3*5 << endl;


    do I just need to put it as

    cout << "2 + 3 * 5=" << (2+3*5) << endl;
     
  2. jcsd
  3. Sep 14, 2008 #2
    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?
     
  4. Sep 14, 2008 #3

    Defennder

    User Avatar
    Homework Helper

    I'm pretty sure you can't mix string output together with variables. You must separate them into with <<.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: The following C++ program does not compile
  1. C Programming Compiler (Replies: 11)

Loading...