C - Data Types

Data type specifies the type of data, entered by the user. Data types are divided into two major categories:

  1. Primary Data Type
  2. Secondary Data Type

Primary Data Type

Primary data type are also known as Primitive or Pre-defined data types. It is divided into 3 categories.

  1. Integral (Non-Decimal): Only integer values are allowed.
  2. Real (Decimal): In Real data type, decimal values can be used.
  3. Character: Character data type can store only single character.
Integral (Non-Decimal) Data Type
S.No. Data Type Size Format Range
signed int
2 Bytes %d -32768 to 32767
unsigned int
unsigned short int
2 Bytes %u 0 to 65535
long int
4 Bytes %ld -2147483648 to 2147483647
unsigned long 4 Bytes %lu 0 to 4294967295
long long int 8 Bytes %ld -263 to 263-1
Real (Decimal) Data Type
S.No. Data Type Size Format Range
float 4 Bytes %f -3.4e38 to 3.4e38
double 8 Bytes %lf -1.7e308 to 1.7e308
long double 10 Bytes %LF -1.7e4932 to 1.7e4932
Character Data Type
S.No. Data Type Size Format Range
char 1 Byte %c 0 to 255
array of char (string) Depends on declaration %s Depends on declaration
Note: The memory size of basic data types may change according to 32 or 64 bit operating system. The above mentioned size is given according to 32 bit OS.

User-Defined Data Types

2. Secondary / Non – Primitive / User Defined Data Types : These data types are defined and use by user according to his requirements. Secondary data types are:

  1. Arrays: collection of values of similar data types.
  2. Pointers: hold the address of a variable
  3. Structure: combine different data types which are related.
  4. Union: Same as structure but it saves memory
  5. Enum: assign number to names
  6. Typedef: Alias of pre-defined data type.