Line breaks in code, print as one sentence. ???

Hey all! I'm new to all this and having trouble with breaking a line apart in the code (my prof won't let the code go past 85 columns), but I need it to print as one line once it runs.

1
2
3
  cout <<"Your spherical object of weight " << static_cast<int>(objWeightlbs) << \n;
     <<" pounds and " << static_cast<int>(raduisft) <<" feet has a buoyant \n";
     <<"force of " << buoyForce << " Newton, and will not float." << endl;

If there is anything I'm doing wrong, please let me know. When I have it like this, I get error: expected primary-expression before '<<' token on both the 2nd and 3rd lines.
Replace the \n on the first line with endl; or "\n"

Remove the semicolons at the end of the first and third line.


1
2
3
 cout <<"Your spherical object of weight " << static_cast<int>(objWeightlbs) << endl
     <<" pounds and " << static_cast<int>(raduisft) <<" feet has a buoyant \n"
     <<"force of " << buoyForce << " Newton, and will not float." << endl;
Last edited on
I'm not getting any errors now, but when it does the output it's still writing it as
The object of weight #
pounds and radius # feet has a buoyant
force of # Newton, and will not float.

Is it even possible to have it be "The object of weight # pounds and radius # feet has a buoyant force of # Newtown, and will not float." ?
Yes. Simply remove the remove the line breakers, which are "\n" and endl
Topic archived. No new replies allowed.