Notes / C / Variables

Variables in C — Revision Notes

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

beginner 📖 2 min revision

Definition

📌 Variables A variable is a named piece of memory that stores a value your program can read or change.

Syntax

syntax
type variableName = value;

// declare then assign
type variableName;
variableName = value;

Example

c
#include <stdio.h>

int main() {
    int age = 20;
    float price = 49.99;
    char grade = 'A';

    printf("Age: %d\n", age);
    printf("Price: %.2f\n", price);
    printf("Grade: %c\n", grade);
    return 0;
}

Output

outputAge: 20 Price: 49.99 Grade: A

Important Points

Common Mistakes

Interview Tip

🎯 Before your interview Know the difference between declaration (int x;) and definition/initialization (int x = 5;) — it's a common interview distinction.
Back to notes Read full lesson →