0% found this document useful (0 votes)
29 views22 pages

12-Finding Area of A Triangle Etc.

This document discusses different methods for solving programming problems including finding the area of a triangle, cube value, square root, and adding two numbers without operators. It also covers swapping two numbers using different methods and the differences between local and global variables in terms of declaration, storage, initial values, scope, and lifetime. Local variables are declared within functions/blocks and exist on the stack while global variables are declared at the top of a program and exist in the data area.

Uploaded by

Saikumar Laveti
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views22 pages

12-Finding Area of A Triangle Etc.

This document discusses different methods for solving programming problems including finding the area of a triangle, cube value, square root, and adding two numbers without operators. It also covers swapping two numbers using different methods and the differences between local and global variables in terms of declaration, storage, initial values, scope, and lifetime. Local variables are declared within functions/blocks and exist on the stack while global variables are declared at the top of a program and exist in the data area.

Uploaded by

Saikumar Laveti
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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