Home Tutorials C Tutorial Variables and Data Types
Variables and Data Types

Variables and Data Types


In C, variables act as containers for storing data. Data types specify the size and type of information the variable can hold, such as integers, characters, or decimal numbers.

Common Data Types in C

Data Type Keyword Example Value
Integer int 20, -5
Floating Point float 5.8, 3.14
Character char 'A', '$'

Practical Example

#include <stdio.h>

int main() {
    int age = 20;            // Integer type
    float height = 5.8;      // Decimal type
    char grade = 'A';         // Character type

    printf("Age: %d\n", age);
    printf("Height: %.1f\n", height);
    printf("Grade: %c\n", grade);

    return 0;
}

Key Points for Success

  • Declaration: A variable must be declared (created) before you can use it.
  • Case-Sensitivity: C is strict—age and Age are seen as two completely different variables.
  • Readability: Use descriptive names (like userAge instead of a) to make your code easier to maintain.
Example

🏋️ Test Yourself With Exercises

Take our quiz on Variables and Data Types to test your knowledge.

Browse Quizzes »