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.
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.
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.
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: