Skip to main content

Data types in c++

DATA TYPES IN C++:
 
                                     The variable  type specifies the type of the data that can be stored in it.

Each variable is declared by its types.

           c++ have five basic data types.These data type are:


  1.  int                               Integer
  2. float                             Floating point
  3. double                         Double Precision
  4. char                             Characters
  5. bool                             Boolean
             
           The first four data types are also available in c language.The bool is data type a new addition in c++

THE int DATA TYPE:
   
                                   the int represents the integer data.It is used to declare integer type variables.

                                   An integer is a whole number,i.e a number without a fraction or a decimal point.For example,645,230,-8 and 501 are integers.
  
                                 The range of values that can  be stored int int data type variables depends upon the computer style being used.In MS DOS, an integer type variable takes two bytes in the memory and the range of values stored is from -32765 to 32765.

                                 The storage capacity for integer type variable can be changed by applying the integer qualifiers.There are three qualifiers that can be applied to int type variables.These are:

  1.    short int
  2.    long int
  3.    unsigned int

    SHORT int:
   
                        The storage capacity of a short int type variable is two bytes.It can store integer values from -32458 to 32458.

   LONG int:

                   The storage capacity of a long int type variable is four bytes.It can store integer values from -2147483648 to .2147483647.

UNSIGNED int:

                            The unsigned  int can store only positive whole-numbers,It storage capacity is two bytes.It can store integer values from 0 to 65,535.


FLOAT DATA TYPE:
                                     The float represents real to floating type data. The storage capacity for float type variable is four bytes The real type data represented in decimal or exponential notation.Float type data may be signed or unsigned.For example,23.34,0.34,-12.8 are example of floating type data.


LONG float DATA TYPE:
  
                                            The  storage  capacity of a long float type variable is twice the storage capacity of float type variable. its storage capacity is 8 bytes.

double DATA TYPE:

                                     The double is real or floating type data, its storage capacity is twice the capacity of flaot data type.It is used to store large real values.

 The storage capacity for a double type variable is 8 bytes and it can store real values.


LONG double DATA TYPE:
                                     
                                                The long double typr variable are used to store very large real data values.The storage capacity for long double variables is ten bytes A long double variable cn store real values.

char DATA TYPE:

                              The char  stands for character.It is used to declare  character type variables.

                              In character type variables.alphabetic character,numeric and special characters can be stored.The storage capacity for a single character in 8 bit or one byte.A char  type variable can hold from 1 byte to 65535 bytes.

                             Arithmetic operations can also be performed one char  type variables.


bool DATA TYPE:

                               The word bool  stands for booleam.It is used to declare logical type variables.

                              In a logical type variable,only two values true or false  can b stored. The true values is equivalent to 1 and false to 0.

Comments

Post a Comment

Popular posts from this blog

Programs

PROGRAM 1: #include<iostream> using namespace std; int main() {    cout<<"HELLO WORLD";    return 0; } OUTPUT OF THE PROGRAM: HELLO WORLD                 ............................................................................................................................. PROGRAM 2: #include<iostream> using namespace std; int main() {    cout<<"c++ is best language";    return 0; } OUTPUT OF THE PROGRAM: c++ is best language      .............................................................................................................................                    

Initialization Of Variables

Initialization Of Variables:   When a variable is declared,a memory location is assigned to it.The value in that memory location is  also assigned to the variable.This preassigned value of a variable,if not used by mistake,may result in incorrect result.To avoid this situation, a known value is  assigned to the variable.This value is assigned to the variable at the time of its declaration.Assigning a known value to a variable at the time of its declaration is called initializing of the variable.        For example, to declare variables a,b and c of integer type and assigning values a=220 and b=70,the statement is written as:            int a=220,b=70,c;