Monday 25 August 2014

As you know that C++ is a computer language and far of human mind.It is only understand by computer.A programmer write a set of instructions in this language to perform the desired work from the computer.The computer read these instructions and give output according to the code.This set of instructions is called "code" also.
So the students i shall provide you the basic concepts of programming through which you will able to write and understand the programming codes.
Firstly I shall provide simple and easy information about these following topics.

  1. Declaration of Variables:-
  2. Data Types:-
  3. Difference B/W Initialization,Declaration and Assignment of variable:- 
  4. Comments:-
  5. Loops:-
Declaration of Variables:-
Variables are the basic and an important part of any computer language.We store values according to our need and then use these variables in the code to perform operations and get desired information.
There are some instruction or rules to declare a variable.These are as follows:-
  1. Variable name can be 1-30 character  long.
  2. It can include  A-B,0-9 and special characters.
  3. The name of variable cannot be start from a number.
  4. The name of variable can start from special character.
  5. Space cannot be used in the name of variable.
  6. _ is used at the start of variable name.
Syntax:-  Data Type     Name of Variable = Value;
In the Following picture you will be clear about Variable.

In above picture "int" is data type of variable and "answer" is the name of variable and "42" is the value which is stored in variable.And don't worry about Data type we discus this topic in detail.
According to syntax you can verify that the variable declared in the pic is correct.
This process of declaring a variable is called initialization.
Declaration , Initialization and Assignment of variable:-
There is a minor difference between declaration and initialization of a variable.  
In declaration of variable we declare a variable only and give no initial value to the variable.It means that we define only data type and name of variable in declaration.But in initialization we give a initial value to the variable but at the time of declaration of variable.
Following picture explain the difference between declaration,initialization and assignment:-


In above picture we declare a variable named "a"  having type "int" and store value "10" in this variable. 

No comments:

Post a Comment