C Programming Language Syntax
Basic Syntax
- Each line of C code is a statement that ends with a semicolon
; - Code is written in functions, which contain statements and expressions
- Comments start with
/* and end with */
Variables
- Variables must be declared before they are used
- Declaration starts with the data type (e.g. int, char) followed by the variable name
- Multiple variables can be declared on the same line, separated by commas
Control Flow
- Conditional statements:
if, else, switch - Loops:
for, while, do-while
Functions
- Functions must be declared before they are called
- A function declaration includes the return type, name, and parameters (if any)
Pointers
- Pointers are used to store memory addresses
- The
* operator is used to declare a pointer variable and to access the value of the variable it points to & operator is used to get the address of a variable