Hello World

I am just starting C++ and already i cant even get past the very first program.

this is the code:

#include <iostream>

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


and these are the errors:

4 expected unqualified-id before '{' token

4 expected `,' or `;' before '{' token


i dont understand what these errors mean can someone please help
You have a semicolon after main(), you don't want one there. Secondly, you need to either have using namespace std; somewhere, or type std::cout.
What he said,
either put using namespace std;
after your header #include <iostream>
or put a using std::cout; ,
or put a std before your cout like std::cout<<"HELLO WORLD"<<std::endl;
you will discover that your program needs a pause to display the output,
either put a cin.get() before your return 0; or add this
1
2
3
4
5
 // For This Method You need to #include <limits>
 cout<<"Push Enter To Quit"<<endl;
 cin.sync();
 cin.ignore(numeric_limits<streamsize>::max(),'\n');
 return 0;

Last edited on
Topic archived. No new replies allowed.