What is Datatype in C Programming language ?

What is Datatype in C language ?
What is Datatype in C language ?



Upon completing this article,you will be able to know:
  • What is Datatype in C language ?
  • How many types of Datatype available in C language ?
  • What is Primitive Datatype in C language ? detailed

Data Type in C:-

C language rich in data type,Storage representation and machine instruction to handle constants differ from machine to machine. The variety of data types available allow the programmer to select the appropriate to the need of the application as well as the machine.

ANSI C support three classes of data type:

  1. Primary(or fundamental) data type
  2. Derived data type
  3. User defined data type

The Primary Data type in C:-

The primary data type are also know as primitive or fundamentals data type of C language.All C compiler support five fundamental data type,namely integer(int),character(char),floating point(float),double precision floating point(double) and void.

Primitive Datatype is classified into following categories:


Integer(int) Datatype in C:-

Integer are whole number with a range of values supported by a particular machine.Generally,integer occupy one word of storage since word sizes of machine vary(typically 16 or 32 bit) the size of an integer that can be stored depends on the computer.

If we use a 16 bit word length,the size of the integer value is limited to range -32768 to +32767(that is -2e15 to +2e15).

A signed integer use one bit for sign and 15 bits for magnitude of the number.similarly,a 32 bit word length can store ranging from -2,147,483,648 to 2,147,483,647.

C has three classes of integer storage,namely

  1. short int
  2. int
  3. long int
short int represent fairly small integer value and requires half amount of storage as regular int number uses.Unlike signed integers,unsigned integers use all the bits for the magnitude of the number and are always positive.

Therefore,for a 16 bit machine,the range of unsigned integer numbers will be from 0 to 65,535.

We declare long and unsigned integer to increase range of value of integers.

The use of qualifier signed on integers is optional because the default declaration taken as signed numbers.

Integer datatype usually stored in 16 bits(2 byte) of internal storage.

Example:  int a=45;
                 short int a=20;
                 long int b=678;

Character (char) Datatype in C:-

A single character defined as a character(char) type data.Character are usually stored in 8 bits(1 byte) of internal storage.

The qualifiers signed or unsigned may be explicity applied to char .While unsigned char have value between 0 to 255,signed char have value from -128 to 127.

Example:   char a;

Floating(float) Point Datatype in C:-

floating point(or real) numbers are stored in 32 bits (on all 16 bit and 32 bit machines),with 6 digit of precision.Floating point numbers are defined in C by  the  keyword float.

When the accuracy provided by float number is not sufficient,the type double can be used to define the number.A double datatype number uses 64 bits giving a precision 14 digits.

Float datatype usually stored in 64 bits(4 byte) of internal storage.

Example:  float a=12.34


Void Datatype in C:-

The void datatype has no values.This is usually used to specify the type of functions this type of function is said to be void when it does not return any value to calling function.It can also play the role of a generic type, meaning that it can be represent any of the other standard types.

Note: 
The primary datatype and their types are discussed in this article.The User-defined datatype are in the next section while the derived data types such as array,functions,structures and pointer are discussed as and when they are encountered.

Conclusion:-
In this article we have learn about What is datatype in C language?,different types of datatype in C and What is primitive datatype in C language? I hope you have no any doubt after reading this article but if if you any doubt than feel free comment below.              
Post a Comment (0)
Previous Post Next Post