Tuesday, 24 May 2016

Variables in C++

   “Variable is a memory location in C++ programming language. ” Variables are used to store data on memory. A quantity whose value may change during execution of the program is called variable. It is represented by a symbol or a name. During programming we need to store data. This data is stored in variables. Variables are locations in memory for storing data. The memory is divided into blocks. It can be viewed as parrot-holes. You can also think of it as PO Boxes. In post offices there are different boxes and each has an address. Similarly in memory, there is a numerical address for each location of memory. It is difficult for us to handle these numerical addresses in our programs. So we give a name to these locations. These names are variables. We call them variables because they can contain different values at different times.
A variables presents a storage or memory location in the computer memory. Data is stored into the memory location. The name of the memory location, i.e. the variable name, remains fixed during execution of the program but the data stored in that location may change from time to time.
A scope is a region of the program and broadly speaking. There are three places where variables can be declared.
Ø  Inside a function or a block which is called local variables.
Ø  In the definition of function parameters which is called formal parameters.
Ø  Outside of all functions which is called global variables.

No comments:
Write comments

Theme images by MichaelJay. Powered by Blogger.

Follow by Email

Blog Archive

Social stratification

Definition Social stratification is one of the results of ongoing social processes taking place. Every society is segmented into differen...

footer

Labels