Data Types in C Language

Data Types
When we declare a variable in ‘C’ language, it is required to specify the data type of variable. The data type specify the:-
            i). Type of value a variable can store
            ii). Range of value a variable can store
            iii).Type of operations that we can perform on the variables.

In C Language, we can classify the data types into following:-
1.      Built-In Data Type                                         
2.      User Defined Data Type
3.      Derived Data Type


1].Built-In Data Type
The Data types which are provided by the C Language is called as built-in data type. They are mainly used to declare variables and function in a program. They are also helpful when we create user defind data type or derived data type.

C language provides five built-in data type
1.      int
2.      float
3.      double
4.      char
5.      void

1].Integer:-This data type is used to store numeric values which do not have decimal part. The int keyword is used to declare this type of variable. It occupies two bytes(16 bits) of memory. It can store any number between -32768 to 32767.This is because int require two bytes (16 bits) to store a number.
int Num=10;               

2]. Float: - This data type is used to store numeric value which have decimal part with six digit of precision. The float keyword is used to declare this type of variable. It occupies four bytes of memory. It can store any number between 3.4e-38 to 3.4e+38.
float Mark=85.50;

3]. Double:-It is the extension to the float data type. It stores a decimal number with sixteen digits of precision. The double keyword is used to declare this type of variable. It occupies eight bytes of memory. It can store any number between 1.7e-308 to 1.7e+308.
double Result=15678.1236547;

4]. Character:-This data type is used to store a single character at a time. The char keyword is used to declare this type of variable. It occupies one byte of memory. C language follows the ASCII character set. The ASCII character set has total 256 characters.It can store any number between -128 to 127.All the character value must be enclosed with a single quote.
char ch=’C’;

5]. Void: -This data type is only used with function and pointer. We can not use it with variables, constant, array, string and structure. The void means simply nothing.

SNo
Name
Byte
Range
1
int
2
-32768 to 32767
2
float
4
3.4e-38 to 3.4e+38
3
double
8
1.7e-308 to 1.7e+308
4
char
1
-128 to 127
5
Void
-
-

Note:- The C language uses scientific notation to help you write lengthy floating-point numbers. In scientific notation, a number can be represented by the combination of the mantissa and the exponent. The format of the notation is that the mantissa is followed by the exponent, which is prefixed by e or E. Here are two examples:

[mantissa]e[exponent]                                     OR                  [mantissa]E[exponent].

For instance, 5000 can be represented by 5e3 in scientific notation. Likewise, -300 can be represented by -3e2, and 0.0025 by 2.5e-3.

2]. User Defind Data Type
The ‘C’ language provides the facility by which the user can create custom data type with the help of built-in data types. These data type are called User defind data type.

The following are the user defined data types in ‘C’ language

1.      Structure
2.      Union

3.      Enum


Derived Data Types

1.      Array
2.      String

3.      Typedef

Comments