Simple and Compound Statements in C

A Statement is the smallest standalone element of a programming language which in itself is collection of tokens of the language put in some proper sequence as per the syntax rules or grammar of the language. A sequence of one or more statements gives rise to a program. C language makes a distinction between statements and definitions, with a statement only containing executable code and a definition declaring an identifier.

The body of C functions (including the main() function) are made up of statements. These can either be Simple Statements or Compound Statements.

Simple Statements do not contain other statements and end with a semicolon called Statement terminator. The simplest kind of statement in C is an expression. The following statements are simple statements and most of the statements in a typical C program are Simple Statements of this form.

Screenshot from 2020-07-11 20-34-11

Screenshot from 2020-07-11 20-35-16

Compound Statements have other statements inside them; may be simple or other compound statements. The term Compound Statement (or Block) refers to a collection of statements (both Simple and Compound) that are enclosed in braces to form a single unit. Compound statements are not terminated with semicolons. The statement shown below is a compound statement. Notice that it contains three simple statements enclosed in a pair of curly braces. Also, though individual simple statements end with semi-colon, however the compound statement does not have one.

Screenshot from 2020-07-11 20-36-32

Compound statements generally from the body of functions, loops conditional statements, and so on.