Hello World

I have wrote the following code yet when I compile it, i fail to get the desired outcome.

#include <iostream>
using namespace std ;


\\ A C++Program to output a greeting.


int main()
{
cout << "Hello World!" << endl ;
return 0;
}

After inputting c:\MyPrograms>c++ hell.cpp in to command prompt and get ->

hello.cpp:5:1 error: stray '\' in program
\\ A C++Program to output a greeting.
^

Any help would be appreciated.

-MnxBUCKethead
Your comment is the following:
\\ A C++Program to output a gretting.

Comments should be done as follows:
// A C++Program to output a gretting.
and you can delete his endl here:

cout << "Hello World!" << endl ;

and write it like that:

cout << "hello world!" ;
kugi wrote:
and you can delete his endl here:

cout << "Hello World!" << endl ;

and write it like that:

cout << "hello world!" ;


You could, but there's nothing wrong with having that endline there. It's not causing any problems, and it's certainly not responsible for the OP's compilation issues.

EDIT: And both you and the OP should learn to use code tags when posting here:

http://www.cplusplus.com/articles/z13hAqkS/
Last edited on
Topic archived. No new replies allowed.