Basic C++ Syntax
Basic C++ Syntax
In this tutorial, we will learn basic C++ syntax. C++ syntax is very similar to C and Java.
Statement Terminator
In C++, the semicolon is the statement terminator. Each code statement
should end with a semicolon.
Examples:
int a ;
a = 10;
We can even write two statements in a single line.
int a; a = 10;
C++ Comments
Single line comments start with a //
Multi-line comments start with /* and end with */
Code blocks
A code block is a set of logically grouped statements surrounded by opening and closing braces. In the C++ program, curly braces denote a code block.
The main function or routine block is denoted by the curly braces. The source code formatting can have different options and styles.
Allman (ANSI) Bracket style:
The curly braces are placed in the next line and the code block statements are indented to the next level.
int main() { cout << "Hello, World!"; return 0; }
—
C++ Tutorials
C++ Tutorials on this website: