Search Your Topic

config
Friday, 19 May 2017 04:15

C Programming Data Types

Written by
Rate this item
(0 votes)

In the C programming language, a data type refers to an extensive system for declaring variables of different types. The language itself provides basic arithmetic types and syntax to build array and compound types. Several headers in the standard library contain definitions of support types, which have additional properties, such as exact size, guaranteed.

C - Basic Data types

The C language provides many basic types. Most of them are formed from one of the four basic arithmetic type specifies in C (char, int, float and double), and optional specifies (signed, unsigned, short, long). All available basic arithmetic types are listed below:

C has a concept of 'data types' which are used to define a variable before its use. The definition of a variable will assign storage for the variable and define the type of data that will be held in the location.

The value of a variable can be changed any time.

C has the following basic built-in datatypes.

  • int
  • float
  • double
  • char

Please note that there is not a boolean data type. C does not have the traditional view about logical comparison, but thats another story.

int - data type

int is used to define integer numbers.

    {        int Count;        Count = 5;    }

float - data type

float is used to define floating point numbers.

     {        float Miles;        Miles = 5.6;    }

double - data type

double is used to define BIG floating point numbers. It reserves twice the storage for the number. On PCs this is likely to be 8 bytes.

     {        double Atoms;        Atoms = 2500000;    }

char - data type

char defines characters.

 

    {        char Letter;        Letter = 'x';    }

Modifiers

The data types explained above have the following modifiers.

  • short
  • long
  • signed
  • unsigned

The modifiers define the amount of storage allocated to the variable. The amount of storage allocated is not cast in stone. ANSI has the following rules:

         short int <=    int <= long int            float <= double <= long double

What this means is that a 'short int' should assign less than or the same amount of storage as an 'int' and the 'int' should be less or the same bytes than a 'long int'. What this means in the real world is:

 

 

Read 478 times Last modified on Wednesday, 13 September 2017 07:13
Anish Sir

"I am delighted once again to pen the welcome note to the Tosh!Yas Technologies ."

 Call +91 74 88 34 7779  | Email : anishsingh@live.com

toshiyas.in

Leave a comment

Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.