You are on page 1of 22

Eg. finding area of a triangle.

Finding cube value.


Eg. finding SQRT of given no.
Eg. Add two numbers without using + operator.
Eg. Swap of two numbers [ interchange ]:
Method 1: without using operators.
Method 2: swap using 3rd variable.
Method 3: without using 3rd variable.
Basically we are using 2 types of variables.
1. Global variables
2. Local variables
Local variables Global variables
Declaration Within function or block { } At the top of program
Storage Stack area Data area
Initial values Garbage Int-0, float-0.0, char-
blank
Scope[where we Within function From anywhere
can use]
Life time [ until Until function execution Until total program
what time they execution
are active in
memory ]

Eg. finding initial values of local and global variables


Finding scope of local variable.
Finding scope of global variable:
Finding life time of local variable:

You might also like