Data types in C

Share Your Love

Each variable in C should be initialised or defined with a data storage format to continue with the operations in the program. These data storage formats are known as data types. A variable should be defined with a data type before using it in the program. 

Data types in C are divided into 4 different types:

  • Basic data types
  • Enumeration data type
  • Derived data types
  • Void data type

Let us discuss them one by one.

Basic data types:

basic data types
Basic Data Types

Integer (int) data type:

  • This particular data type helps you to store numeric values.
  • It is should be represented by the int keyword.
  • It cannot store decimal values.
  • In 16 bit processor, it takes 2byte of memory to get allocated.
  • In 32 bit processor, it takes 4byte of memory to get allocated.
  • In 64 bit processor, it takes 8byte of memory to get allocated.
  • Example:166

Character (char) data type:

  • This data type helps you to store one character.
  • It should be represented by the char keyword within a single inverted comma.
  • The size of the char in every processor is 1byte.
  • Example: ’R’

Float (float) data type:

  • This data type helps you to store numeric value with decimal.
  • It should be represented by the float keyword.
  • It can store up to 6 digits after the decimal.
  • The storage size of a float is 4, but it varies depending upon the processor.
  • Example:10.324567

Double (double) data type:

  • This data type is the same as that of float holding decimal values.
  • It is should be represented by double keyword.
  • It can store up to 10 digits after decimal.
  • The storage size of double is 8.

The program below shows the example of the different basic data type.

Fbw gbsLnWeNd PgndaTL4G MCvV2WWXp4VQ o4NFywNlfCXB3vt00inCY4tuV87H p773f0a B td tRVaajLDlZRdhOGaaNMuSko

Enumeration data type:

  • Enumeration is represented by enum datatype.
  • Enumeration data type comprises of named integer.
  • It can be referred to as a list.
  • Example: {ab,cd,ef}

The program below shows the enumeration data type.

ztN r Tw5EByAwcanEGx6yH3rd5WDF0Pr NZB9ZuDrM7oDM4GX3juV1 lXMbbSv33BVSKonrCQX10bjmBge420BaGp fro7fYakhiZbp4iqS0vV9sTvz4uS3H6 kTF4MftbGlQ

Derived data types:

  • These data types are derived by the user itself.
  • They consist of array, pointer, structure, union.
  • We will discuss more about derived data types as we deep dive into the language.

Void data type:

  • As the name specifies, void is an empty data type.
  • It has no value.
  • They can be used in functions and pointers.

Hence we come to the end of the discussion on data types in C language.

Please write comments or WhatsApp if you find anything incorrect, or you want to share more information about the topic discussed above.

Share Your Love
Avatar photo
Soham Malakar

Hello my name is Soham Malakar am currently pursuing BCA

Coding is one of my favorite hobbies.
I love to code and an enthusiast to learn different types of programming languages.
I love to get intoxicated in the world of technology and video games.
A quick learner possessing better results.

Articles: 40

Newsletter Updates

Enter your email address below to subscribe to our newsletter