Previous Next

C Data Types

A C data type declares the data type that a variable can hold.

C provides several built-in data types, including:

Data Type Size Description
int 2 or 4 bytes Stores whole numbers, without decimals
float 4 bytes Stores fractional numbers, which have one or more decimals.
char 1 byte Stores a single letter/character/numbers
double 8 bytes Stores fractional numbers, having one or more decimals.

Example

#include <stdio.h>

int main()
{
    int integer = 40;
    float floating = 20.42;
    char character = 'D';

    printf("%d\n", integer);
    printf("%f\n", floating);
    printf("%c\n", character);
    return 0;
}

Output:

40
20.420000
D
Previous Next