C++ Syntax

C++ Syntax

Let's break down a simple C++ program to understand its syntax. Every C++ program consists of statements that the computer will execute.

A Simple C++ Program

Here is the classic "Hello World" program in C++:

Example

#include <iostream>
using namespace std;

int main() { cout << "Hello World!"; return 0; }

Line-by-Line Explanation

Remember, C++ ignores white space, but standard indentation makes code easier to read.


Exercise

?

What punctuation mark must be used to end every statement in C++?