Hello World in C++

Learning programming language is easy. You need only compiler or IDE, and then you can copy and paste Hello World code from the internet. For example, if you use C++.

#include <iostream>

using namespace std;

int main(){
    cout << "Hello, world!";
    return 0;
}
Output :
Hello, world!

You can create new empty project, copy and paste that code to IDE. After that, you can look for "build and run button" to run your program.

If you don't have IDE, you can download Code::block or other IDE.

Print Other Sentences

Cout is one of standard C++ function to print output. You can print other output by using cout. Change every letters between two apostrophes after cout, and you will see other output. For example, if you want to write "Yay, I can write code in C++!".

#include <iostream>

using namespace std;

int main(){
    cout << "Yay, I can write code in C++!";
    return 0;
}
Output :
Yay, I can write code in C++!

All letters between apostrophes is called as string literal.

Statements

Statement is a task or action in programming language. In C++, a statement is ended by semicolon. When you write a code to print "hello world", there is one statement to print string literal. You also have a return statement inside main function.

You can add one or more statements inside "main function". For example, if you want to print 2 "Hello, world!", you can copy a statement with cout. So you will have 2 similar statements to print to the output.

#include <iostream>

using namespace std;

int main(){
    cout << "Hello, world!";
    cout << "Hello, world!";
    return 0;
}
Output :
Hello, world!Hello, world!

Endl

Endl is used to print end of line character. So, the cursor will move to the next line.
#include <iostream>

using namespace std;

int main(){
    cout << "Hello, world!";
    cout << endl;
    cout << "Hello, world!";
    return 0;
}
Output :
Hello, world!
Hello, world!