Skip to main content

Expressions and Statements in C


Expression

A combination of operands and operators that produces a value is called an expression.
c = a + b;
PartRole
a and bOperands
+Arithmetic operator
=Assignment operator
a + bExpression (evaluates to a value)
More examples:
x * y          // arithmetic expression
x > y          // relational expression (true/false)
x && y         // logical expression
x = 5          // assignment expression — returns 5

Statement

A statement is a complete instruction in C that performs an action. Most statements end with a semicolon (;).

Types of Statements

Declaration Statement — creates a variable:
int x;
Assignment Statement — assigns a value:
x = 10;
Expression Statement — evaluates an expression:
a + b;
x++;
Function Call Statement — calls a function:
printf("Hello");
scanf("%d", &x);
Control Flow Statement — changes execution order:
if (x > 0) { ... }
while (x < 10) { ... }
for (int i = 0; i < 5; i++) { ... }
Compound Statement (Block) — a group of statements enclosed in {}:
{
    int a = 5;
    int b = 10;
    int c = a + b;
}
A block is treated as a single unit. Variables declared inside a block are local to that block.

Key Difference

ExpressionStatement
DefinitionProduces a valuePerforms an action
Examplea + bint a = 5;
Ends withNo semicolon neededSemicolon ;