Hello There, Guest! RegisterLogin with Facebook
Login with Facebook

>>> Anna University Sixth Semester Question Bank Collection (R2013) ECE,MECH,CSE,IT,EEE,CIVIL,EIE
>>> Anna University Study Materials for all Departments
>>> Anna University Question Papers : April May June 2015 Question Papers | Nov Dec 2014 and Jan 2015 Question Papers

Register or Login to Submit Study Materials , Shoutbox and also to access Many Features !!

Vidyarthiplus Shop :: Handwritten Premium Lecture Notes
Share your Study Materials with us
Share your Study Materials with us : Click Here

General concepts - Data Types - Variables - Assignment


Data types:  
  •             Data types are just like initials.
  •             Data types are the kind of data that the variable use in programming languages.

  •              Generally the data types are classified as


  •              The data type "int" holds 2 byte values, whereas "float" holds 4 bytes, and "char" data type holds 1 byte and "double" data type holds 8 bytes.

  •               A particular variable can point to  a single data type throughout the program.
  •               The concept of data type differs when we use a templates
  •                When we use templates, a variable may point to a unknown data type. (i.e) a generic pointer.
  •               Variables are the memory location that the variable use in programming languages.
  •                 A variable can be name of a person, or anything else.A user defined name can be defined to a variable.
  • Rules for declaring a variables:
  •                The variable must starts with an alphabet or an underscore i.e( _ ) followed by alphabets or numbers.
  •                  No special characters except underscore should be used.
  •                  The special words or reserved words i.e the keywords should not be used.

Syntax for a variable:

data_type variable_name;

int num;
float avg;
double area;
char name;

Declaring variable while using templates
template <class a>
class sample
   a ex;
     void fun()
         cout<<"using templates";
     void getdata()
           cout<<"enter a integer value";
           cout<<"enter a float value";
           cout<<"enter a char value";
    The above program is implemented using templates.Here the variable "ex" is of generic type.(i.e) unknown data type.
    Hence it can take values for integer, or float, or character.

Assigning values:

    Values to a variable can be assigned in two ways:
          i) Direct assignment
          ii) Run time assignment

Direct assignment:
     Direct assignment to a variable is nothing but initialization of variables.
eg: int num=10;

Here the variable num takes the value 10 initially.Since it is a variable the value may be changed.

Run time assignment:

The values for the variables can be read from the user during the runtime.
(i.e) char name;
       cout<<"enter your name";

Fear is a reaction,but courage is a destination



Recommend on Google

Vidyarthiplus Whatsapp