Create, Compile and Run the Hello World Program in C++
C++ programs can be written in a very easy manner, follow the below two steps to create, compile and run the program.
1. Open a text editor, write the following "Hello World" program and save the file with .cpp extension i.e. HelloWorld.cpp
Hello World Program - HelloWorld.cpp
#include<iostream>
using namespace std;
int main(int argc, const char * argv[])
{
cout << "Hello World";
return 0;
}
2. Compile the cpp file (i.e. C++ program) using the command g++ -o HelloWorld HelloWorld.cpp and execute the compiled code using the command HelloWorld (i.e. name of the compiled file)