Skip to main content
Submitted by admin on 29 November 2023

Additional info:

Why do we need Data Types

Data types are necessary for the following reasons.

  • Where size matters when storing data.
  • For internal binary representation of data
  • Where do we need to perform various operations?
Where size matters.
Let us take an example. In a almirahs, we have three different spaces as per the requirements, let's say if you want to keep clothes then there is separate space for that and also a drawer where you can keep some other things, the drawer has a There are also small drawers where you can keep your luxury items or cash, so you use that space as per requirement, not that you will keep clothes in a small space.
You can take another example, suppose if you have to take water then you will use a glass. And if you have to take any other thing like vegetables, then you will use a bowl, it is not that you will use a glass for vegetables, so you will take those things as per requirement.

It's types

Data types are broadly divided into two types.

1. Primitive data type

Built-in data types in a C language that are in the form keywords as below are called primitive data types.

Example: char, double, float, int, void

char Data Type

charData Types are of two types.

1. Signed char (by default)
may be positive or negative
  • Size: 1 byte
  • Range: -128 to 127 (27 - 1)
2. Unsigned char
Positive numbers only.
  • Size: 1 byte
  • Range: 0 to 255 (2n - 1)

int Data Type

  • Size: 4 bytes
  • Range: -2,147,483,648 to 2,147,483,647

int are three sub types In C programming, short, long, and long long int are different data types that store integers. They have different ranges and consume different amounts of memory.

1. short int
Consumes 16 bits, has a maximum value of 32767, and takes up 2 bytes of storage space.
  • size: 2 bytes
  • range: -32,768 to 32,767
2.long int
Consumes 32 bits, and takes up 8 bytes of storage space in 64-bit operating systems and 4 bytes in 32-bit operating systems.
  • positive or negative numbers.
  • size: 8 bytes or (4bytes for 32 bit OS)
  • range: -9223372036854775808 to 9223372036854775807
Unsigned long
  • positive numbers only
  • size: 8 bytes
  • range: 0 to 18446744073709551615
3.long long int
long long int uses 64 bits.
  • positive numbers only
  • size: 8 bytes
  • range: -128 to 127 (27 - 1)

unsigned int Data Type

  • size: 4 bytes
  • range: -2,147,483,648 to 2,147,483,647

2. Non Primitive data type

user-defined data types are called non primitive data types.

Example: Structures, Unions, Enums, Pointers, Arrays, Functions