Expressions and Statements in C
Expression
A combination of operands and operators that produces a value is called an expression.| Part | Role |
|---|---|
a and b | Operands |
+ | Arithmetic operator |
= | Assignment operator |
a + b | Expression (evaluates to a value) |
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:{}:
Key Difference
| Expression | Statement | |
|---|---|---|
| Definition | Produces a value | Performs an action |
| Example | a + b | int a = 5; |
| Ends with | No semicolon needed | Semicolon ; |