Let's break down a simple C++ program to understand its syntax. Every C++ program consists of statements that the computer will execute.
Here is the classic "Hello World" program in C++:
#include <iostream> using namespace std;int main() { cout << "Hello World!"; return 0; }
#include <iostream>: This is a header file library that lets us work with input and output objects, such as cout.using namespace std: This means that we can use names for objects and variables from the standard library.int main(): This is the main function. Any code inside its curly brackets {} will be executed when the program runs.cout << "Hello World!";: cout (character output) is used to print text to the screen. Every C++ statement must end with a semicolon ;.return 0;: This ends the main function and returns 0, indicating that the program ran successfully.Remember, C++ ignores white space, but standard indentation makes code easier to read.
What punctuation mark must be used to end every statement in C++?