Data Types in C

Data type defines the type of data a variable can hold. C language has some predefined set of data types to handle various kinds of data that we can use in the program. These data types have different storage capacities.

C Data Types

The different types of data types as classified below in C language.

  • Basic or Primary data types
  • Derived data types
  • User Defined data types
Basic or Primary data types

They are the primitive or fundamental data types in C. They can be classified further as Integer(int), floating point(float), character(char) and void. The void type specifies that no value is available. It is used in the situation when a function returns no value or it does not accept the parameters.

C language supports both signed and unsigned literals.

The memory size of the basic data types may change according to 32 or 64-bit operating system.

Let's see the basic data types. Its size is given according to 32-bit architecture.

Data TypesMemory SizeRange
char1 byte−128 to 127
signed char1 byte−128 to 127
unsigned char1 byte0 to 255
short2 byte−32,768 to 32,767
signed short2 byte−32,768 to 32,767
unsigned short2 byte0 to 65,535
int2 byte−32,768 to 32,767
signed int2 byte−32,768 to 32,767
unsigned int2 byte0 to 65,535
short int2 byte−32,768 to 32,767
signed short int2 byte−32,768 to 32,767
unsigned short int2 byte0 to 65,535
long int4 byte-2,147,483,648 to 2,147,483,647
signed long int4 byte-2,147,483,648 to 2,147,483,647
unsigned long int4 byte0 to 4,294,967,295
float4 byte
double8 byte
long double10 byte
Derived data types

They are a twisted group of primary data types. For example, array, structure, union and pointer.

User Defined data types

These data types are defined by the user. They can be of two types- Enum and Typedef.

Both Derived data types and User Defined data types will be discussed in detail in coming sections.

Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +