C Data Type

C programming supports several data types for storing different types of values. In this answer, we will discuss the basic C data types, their sizes, and their ranges.

Basic C Data Types:

C programming supports the following basic data types:

  1. char
  2. int
  3. float
  4. double
  5. void

We will discuss each of these data types in detail.

  1. char:

The char data type is used to store a single character. It is represented using the keyword ‘char’. The size of a char is 1 byte, and its range is -128 to 127 or 0 to 255, depending on whether it is signed or unsigned. The default type of char is signed.

Signed char:

Data typeStorage sizeValue range
char1 byte-128 to 127

Unsigned char:

Data typeStorage sizeValue range
unsigned char1 byte0 to 255
  1. int:

The int data type is used to store integers. It is represented using the keyword ‘int’. The size of an int is typically 4 bytes on most systems, although this can vary depending on the system architecture. The range of an int is -2,147,483,648 to 2,147,483,647. The default type of int is signed.

Signed int:

Data typeStorage sizeValue range
int4 bytes-2,147,483,648 to 2,147,483,647

Unsigned int:

Data typeStorage sizeValue range
unsigned int4 bytes0 to 4,294,967,295
  1. float:

The float data type is used to store single-precision floating-point numbers. It is represented using the keyword ‘float’. The size of a float is 4 bytes, and its range is approximately 1.2E-38 to 3.4E+38.

Data typeStorage sizeValue range
float4 bytes1.2E-38 to 3.4E+38
  1. double:

The double data type is used to store double-precision floating-point numbers. It is represented using the keyword ‘double’. The size of a double is 8 bytes, and its range is approximately 2.3E-308 to 1.7E+308.

Data typeStorage sizeValue range
double8 bytes2.3E-308 to 1.7E+308
  1. void:

The void data type is used to indicate the absence of a value. It is represented using the keyword ‘void’. The void data type cannot be used to declare variables, but it is commonly used as a return type for functions that do not return a value.

Data typeStorage sizeValue range
voidN/AN/A

Conclusion:

In this answer, we discussed the basic data types supported by C programming, their sizes, and their ranges. It is important to understand the characteristics of each data type in order to use them effectively in C programs. By using the appropriate data type for each variable, we can ensure that our programs are efficient and accur