C++ Statements and Functions

C++ program typically consists of multiple functions and statements.

Statements

  • A statement is a basic unit of computation in C++.
  • Every C++ program is a collection of statements.
  • Statements end with a semicolon (;)
  • Statements are executed top to bottom, in sequential order, one after the other statement.

Functions

A function is a sequential set of statements defined in a block of code, accomplishing something.

  • A function can optionally return something to the caller of the function.
  • A function must be defined before it’s use.
  • Functions provide re-usability of code.