Notes / C / Functions

Functions in C — Revision Notes

A quick-reference cheat sheet: definition, syntax, example, common mistakes and an interview tip.

beginner 📖 2 min revision

Definition

📌 Functions A function is a reusable, named block of code that performs a specific task.

Syntax

syntax
returnType functionName(parameterType param) {
    // code
    return value;
}

Example

c
#include <stdio.h>

int add(int a, int b) {
    return a + b;
}

int main() {
    int result = add(4, 7);
    printf("Sum: %d\n", result);
    return 0;
}

Output

outputSum: 11

Important Points

Common Mistakes

Interview Tip

🎯 Before your interview Be ready to explain "pass by value vs pass by reference" in C — C only has pass by value, but you can simulate pass by reference using pointers.
Back to notes Read full lesson →