Using endl

I have only just started to learn C++ and i really would like some help please.
I typed out a multiple expression and ended it with endl but the correct answer appeared but it also had danny@ubuntu:~ along it. How can i separate the two?

1
2
3
4
5
6
#include <iostream>
using namespace std:

int main()
{
   cout << 355 / 5 << " " << 49 / 7endl;
You have to use the stream operator to send the endl to cout, just like everything you're sending.

I'm surprised the code you posted even compiles.
Hi,

It seems that you forgot to use the "<<" operator before the endl. The correct expression should be

1
2
3
4
5
6
7
8
#include <iostream>
using namespace std:

int main()
{
   cout << 355 / 5 << " " << 49 / 7 << endl;
   return 0;
}


I hope this helps.
And it's
using namespace std;
not
using namespace std:
Look VERY carefully @christianwos (or just try to compile it!)
Last edited on
Yes, sorry. I missed that one. Thanks for catching it.
Very big thank you to both christianwos and lastchance for taking the time out and helping a noob like myself.
It's not easy being a noob lol.
BTW, you only need to use endl if it is important to make sure your output is properly flushed (to file) at the end of every write. In almost all cases, a simple newline is enough.

1
2
3
  std::cout << "Hello world!\n";
  std::cout << "I'm " << 3 << ".\n";
  std::cout << "Number of nanobots: " << nanobot_count << '\n';

Hope this helps.
Topic archived. No new replies allowed.