Data Types

C Programming Language becomes very powerful with the help of number of data types linked with it.  Data types vary according to their use. Different compilers have different data types. Actually variable type depends on the data type. Data type is the description of nature of data either in numeric forms ( integer or real) or in the character form ( single character or string). There are mainly five types of data types used in the C programming language. These all are described below –

  • Primary/ Scalar/ Standard/ Fundamental/ Simple data type/ Primitive data type
  • Secondary/ Derived data type or Structured data type
  • User defined/ Enumerated/ Typedef data type
  • Empty data type or void data type
  • Pointer Data type

Primary/ Scalar/ Standard/ Fundamental/ Simple data type/ Primitive data type –

A scalar data type is used for representing a single value only. It is also called simple or Fundamental data type. As these are used at primary level in the high level language, So these are also called Primary data type.  These are further sub divided into four categories –

  • Integer Data type
  • Float data type or single precision real data type
  • Double precision or Double or Long float data type
  • Character Data type

1. Integer Data type-

In C programming language this data type is without decimal point. These are signed or unsigned. These data type are small int(short int), int, long int.  These have 8 bit to 32 bit data and also have different ranges for inputting the data or assigning the data to the variable. The ranges for signed short int be – 128 to +127 whereas unsigned short int have range 0 to 255 and both having 8 bit size. On the other hand signed long int have the long range from -2,147,483,648 to +2,147,483,647 having the 32 bits in size. This data type is declared with the keyword/ reserved word ‘ int ‘. Below is the example of how this data types is declared-

int var1,var2,var3;
int rno,sr_no,marks;
int marks=98;

2. Real/Float/Single Precision data type

These are also called single precision or real data type. These data type have at least one digit with a decimal point. These are also signed or unsigned. These data types require storage space (size) 32 bit and have range 3.4E-38 to 3.4E-38
for inputting the data.  Likewise integer data type, float data type is declared using the same format with the keyword/reserved word  ‘ float ‘.

3. Double Precision Data type

These data types have very large floating data, so are also called large real number. These have double precision value having the 64 bits or 8 bytes size and the range is 1.7E-308 to 1.7E+308

Also there are long double or long float having 80 bits in size and have a very high range from 3.4E-4932 to 3.4E+4932. This data type is declared with the keyword/ reserved word ‘ double ‘.

4. Character Data Type

These have either single character or combination of character (called string). Characters have either signed or unsigned but mostly characters are used as unsigned type. These have 8 bit (1 byte) internal storage.  Also there range varies from 0 to 255 in the case of unsigned character and -128 to 127 in the case of signed character. Character data type is declared using the reserved word ‘ char ‘.  This data type may contain all type of characters like alphabets, numeric and special symbols.  Below is the example to declare the character data type –

char var1,var2,var3;
char var1='c';

char is also declared with the length
char var[length];
char var[15];
char nm[15];
name="cprogramming";

When one character is to be stored in the variable then the single quotes are used and when a string is to be stored in the variable then double quotes are being used. Also while declaring a variable it’s length must be given otherwise it will only store the first character of the string.


Structured/ Derived/ Secondary Data type

Derived data types are derived from the scalar data type by adding some additional relationship with the various elements of the primary or scalar data types. Note that derived data type may be used for representing a single value or multiple values. As these data types have different structure depending on the C coding.  These are further subdivided into three categories:

  • Arrays and Strings
  • Structures
  • Unions

We will study about them in detail in later chapters


User defined/ Enumerated/ Typedef data type

This is also used for type definition, i.e it allows the users to define a variable or an identifier, which is used for representation of existing data types.  In other words, it provides us a way to define our own data type and also can define the value of a variable or an identifier stores into the main memory . These are two types of User defined data types. These are Enumerated or typedef data type.


Void/ Empty Data type

Void or empty data type is used in the user defined function or user defined sub programs. These are used when the function sub program returns nothing. Also it is used when a function or any sub program have not any argument in it. You  will study about this topic in detail in the user defined function chapter


Pointer Data type

Pointer data types are used to handle the data at their memory addresses. You will study about this in detail in the pointers chapter.

yashan has written 70 articles

6 thoughts on “Data Types

  1. ClickRead says:

    I do not know whether it’s just me or if perhaps everyone else encountering issues with your site. It appears as if some of the text within your posts are running off the screen. Can somebody else please provide feedback and let me know if this is happening to them as well? This might be a problem with my browser because I’ve had
    this happen previously. Cheers

Cancel reply

Leave a Reply to youtube.com

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>