DATA TYPE

In C programming language there are various types of Data type that are used during program. Following are some data types in c programming language.

1)   Basic data types

2)   Enumerated types

3)   The type void

4)   Derived types

Data types in C Language

Ø BASIC DATA TYPES

             Basic data type have arithmetic types of data. Basic data types have two types of data types

·       Integer data type

·       Floating data type

                    Integer data types have integer value in its range (i.e. 12.00) and floating data types have float values in its range (i.e. 13.33).

                     Following table provides the details of standard integer types with their storage sizes and value ranges.

 

TYPE

STORAGE SIZE

VALUE RANGE

FORMET SPECIFIER

char

1 byte

-128 to 127 or 0 to 255

%c

int

2 or 4 bytes

-32,768 to 32,767 or -2,147,483,648 to 2,147,483,647

%d

Unsigned char

1 byte

0 to 255

%c

Signed char

1 byte

-128 to 127

%c

Unsigned int

2 or 4 bytes

0 to 65,535 or 0 to 4,294,967,295

%u

short

2 bytes

-32,768 to 32,767

%hu

Unsigned short

2 bytes

0 to 65,535

%hu

long

8 bytes or (4 bytes for 32 bit os)

-922337203685

4775808 to 9223372036854775807

 

 

%ln

 

Unsigned long

8 bytes

0 to 18446744073709551615

%ln

 

Following table are provides the details of floating type values with their storage sizes and value ranges.

 

Type

Storage size

Value range

Precision

float

4 byte

1.2E-38 to 3.4E+38

6 decimal places

Double

8 byte

2.3E-308 to 1.7E+308

15 decimal places

Long double

10 byte

3.4E-4932 to 1.1E+4932

19 decimal places

 

Ø ENUMERATED TYPES

                   They are again arithmetic type and they are used to define variables that can only assign certain discreate integer values throughout the problem. The table of enumerated types of data are as same as basic types of data.

 

Ø THE TYPE VOID

             The void type specifies that no value is available. It is used in three kinds of situations is following as below table.

 

 

Sr no.

Types and Description

1.

 FUNCTION RETURNS AS VOID

        

       There are various functions in c which do not return any value or you can say they return void. A function with no return value has the return type as void. For example :  Void exit(int status);

2.

 FUNCTIONS ARGUMENTS AS VOID

 

        There are various functions in c which do not accept any parameter. A function with no parameter can accept a void. For example : int rand(void);

3.

 POINTERS TO VOID

 

         A pointer of type void * represents the address of an object, but not its type. For example, a memory allocation function void *malloc(size_s size ); returns a pointer to void which can be casted in any data types.

 

Now we discuss about types and its description of basic data types that are mostly used in c program as per following table.

 

Sr no.

Types and Description

1.

  CHAR

   Typically a single octal (one byte). It is an integer type.  

    

2.

  INT

    The most natural size of integer for the machine.

 

3.

  FLOAT

      A single-precision floating point value.

 

4.

  DOUBLE

       A double-precision floating point value

5.

  VOID

         Represents the absence of type.