Let's see one simple example of C++ program and learn some basic syntax of it.
Syntax:
#include <iostream> int main() { std::cout << "Hello World!"; return 0; }
Line 1: #include <iostream> is a statement to include the header file library.
<iostream> is a library that lets us work with input and output functions, such as cout.
Line 2: blank space. C++ ignores white space, but we need white spaces to increase our code readability.
Line 3: the main() function. As its name implies, main() function consists of the main code to be executed.
Any code inside the curly brackets { } is called “inside the main() function”
Line 4: std::cout is a function used to output or print text to the screen.
Line 5: return 0; ends the main() function.
Note: every C++ statement ends with a semicolon (;)