Data types in C

Last Updated Nov 1, 2015, 07:00:14 PM

Data types in c program is an object which determines what type of values an object can have and what operations can be performed on the object

Data types in c program must be defined before using them

Data types in C

C programming has four diffrent types of data types

S.NO Data types Example Types
1 Basic Data types Int, float, float, double
2 Derived Data types Arrays, Pointers, Structures, Unions, Functions
3 Enumerated types Arithmetic types, enums
4 Void Types Void

Let us look at each data type in c

Basic Data types in C

C language has various data types. The most commonly used data types in c are int, char, float, double

The below table shows all the basic data types in C language

Integer Types
Type Description Storage Format Example
signed char
unsigned char
Smallest unit which contains the basic character set 1 Byte %c Try It Now
signed int
Basic signed integer type. The range of int data type is -32767, + 32767 2 or 4 Bytes %i or %d Try It Now
unsigned short
Short signed integer type. The range of short data type is [-32767, +32767 ] 2 Bytes %hi Try It Now
unsigned long
Long unsigned data type. The range of this data type is [-2147483647, +2147483647] 4 Bytes %li Try It Now

The sizeof() function is used to find the size of any data type in c. See the below example for more understanding

Floating-point Data types in C

Floating types are generally of two types float, double


Float data type is used to store the decimal values. We can use upto 6 digits after the decimal. Example(0.556345)


Double data type in c works same as the float data type the only different is we can use upto 15 digits after the decimal

Two important threads on StackOverFlow about float and double data types

When do you use float and when do you use double
Difference between float and double

The following table shows the floating point data types and its values

Data type Size Precision Limit Example
Float 4 Bytes 6 decimals Try It Now
double 8 Bytes 15 decimals Try It Now
long double 10 Bytes 10 decimals Try It Now

Here is an example program for all floating-point data types in c

Void Data type in C

Void data type is nothing but an empty data type that has no value. The void data type in c is used to in functions and pointers