Name: Hello World
Language: C++
IDE: Visual C++ 2005
File Type: Empty Win32 Console Application
//Hello World v1.0
//Coded by Deathlycat
//Demonstrates basic console output
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World! I am teh codes!n";
return 0;
}
//Coded by Deathlycat
//Demonstrates basic console output
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World! I am teh codes!n";
return 0;
}
#include <iostream>
Tells the compiler to use the elements of the input/output header file.
This allows us to write to the console.
using namespace std;
Tells use to use the element std, which stands for standard.
Instead of writing std::cout, we can just write cout.
int main() { }
The main execution code. Every C++ file needs a main function. It does everything, and it can call on other functions. Everything inside the main function is in between the two curly brackets
cout << "Hello World! I am teh codes!n";
Displays "Hello World! I am teh codes!" onto the screen.
cout displays the line (as in c -> out).
<< indicates what cout refers to for printing to the console.
n creates a newline (just like pressing enter on the keyboard. C++ ignores whitespace; spaces, tabs, and returns; they are just there to help programmers organize and see code better)
return 0;
Tells windows that there was no error and that everything went as planned.
return 1, reports that something went wrong.
And there you have it!
The program should print "Hello World! I am teh codes!"
If not, then there was an error!
Also, the semicolon key ( ; ) represents the end of a code snippet. This allows windows to recognize when you use different functions.