Tuesday 1 October 2013

Data Types in C

Keywords                                                                                                                  Operators



Data Types In C:- Data type is used to define which type of data may variable hold. for different types of data C provides many datatypes for decimal value we use float,  for integer value we use int , for character we use char , for string we use string.

There are 2 types:-

1)Primitive Data Type

  •   int
  •   Char
  •   float
  •   double


2) Derived Data Type

  •      Array
  •      pointer
  •      Structure
  •       Enum

int :- used for storing integer values.
Range:-   -32768 to +32767
  int a =10;

char- used for storing character.
Range   -128 to +127
  char aplha = 'a';
storing one character at a time.

float:- used for storing decimal values
Range:-  3.4E +/-38
 float f= 2.8;

double:- used for storing big floating numbers.
Range:- 1.7E +/-308
double d = 2.444444;

Modifiers:-  used for increasing the range of the above data types .

  • short
  • long
  • signed
  • unsigned

we discuss the range of all these in previous chapter named keyword check in this.

Qualifier:- There are two types of qualifier:-

  • const
  • volatile

the value of the variable cannot change throughout the execution of the program which declared as a const.
ex;- const int a =10;

the value of variable is changed by the hardware which is declared as volatile.

Range of all data types:-

int                                                   -32768 to +32767
unsigned int                                      0 to 65535
char                                                -128 to +127
signed char                                     -128 to +127
unsigned char                                   0 to 255
short                                              -32768 to +32767
unsigned short                                 0 to 65535
long                                               -2147483648 to +2147483647
unsigned long                                   0 to 4294967295
float                                                 3.4E +/-38
double                                              1.7E +/-308



We discuss all derived data type in next chapter............

No comments :

Post a Comment