C Programming language

adplus-dvertising
Data Types: Primary Data Types in C Programming Language
Previous Home Next

Primary Data Types

  1. Integer Data Type : Integers are whole numbers with a range of values, Generally an integer occupies 2 bytes memory space and its value range limited to -32768 to +32768. To control the range of numbers and storage space, C has three classes of integer storage namely short int, int and long int. All three data types have signed and unsigned forms. Integer Data Types are denoted by int.
    int <variable name>

    Example

    int num1;
    short int num2;
    long int num3;

    Memory occupied by Integer

    • short int (1 Byte)
    • int (2 Bytes)
    • long int (4 Bytes)
  2. Floating data types : The float data type is used to store fractional numbers (real numbers). Floating point numbers are denoted by the keyword float. The double is same as float but it takes double space (8 bytes) than float.
    float  <variable name>

    Example

    float  num1;
    double  int num2;
    long double int num3;

    Memory occupied by Float

    • float (4 bytes)
    • double (8 bytes)
    • long double (10 bytes)
  3. Character data types : Character type variable can hold a single character. As there are singed and unsigned int (either short or long), in the same way there are signed and unsigned chars; both occupy 1 byte each, but having different ranges. Unsigned characters have values between 0 and 255, signed characters have values from –128 to 127. Character is declared by char.
    char <variable name>

    Example

    char ch='m';
    char name='P';

    Memory occupied by char

    • char (1 byte)
Previous Home Next