C/C++ The following C++ program does not compile

  • Thread starter Thread starter soul5
  • Start date Start date
  • Tags Tags
    C++ Program
AI Thread Summary
The discussion centers on the correct syntax for using the `cout` statement in C++. The initial example, `cout << "2 + 3 * 5 = " 2+3*5 << endl;`, is identified as incorrect due to improper syntax. The correct version, `cout << "2 + 3 * 5 = " << (2+3*5) << endl;`, is confirmed to be valid. Participants emphasize the necessity of using the `<<` operator to separate string outputs from variable outputs in C++. There is a suggestion to compile and test the second example to verify its functionality, highlighting the importance of syntax in avoiding compilation errors.
soul5
Messages
63
Reaction score
0
cout << "2 + 3 * 5 = " 2+3*5 << endl;


do I just need to put it as

cout << "2 + 3 * 5=" << (2+3*5) << endl;
 
Technology news on Phys.org
soul5 said:
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?
 
I'm pretty sure you can't mix string output together with variables. You must separate them into with <<.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Thread 'Project Documentation'
Trying to package up a small bank account manager project that I have been tempering on for a while. One that is certainly worth something to me. Although I have created methods to whip up quick documents with all fields and properties. I would like something better to reference in order to express the mechanical functions. It is unclear to me about any standardized format for code documentation that exists. I have tried object orientated diagrams with shapes to try and express the...
Back
Top