Question: int main() { printf(Global a = %d , a); printf(Global b = %d , b); globalVarFunc(); localVar(); useStaticLocal(); useGlobal(); globalVarFunc(); localVar(); useStaticLocal(); useGlobal(); printf(Global a

int main() { printf("Global a = %d ", a); printf("Global b = %d ", b); globalVarFunc(); localVar(); useStaticLocal(); useGlobal(); globalVarFunc(); localVar(); useStaticLocal(); useGlobal(); printf("Global a = %d ", a); printf("Global b = %d ", b); return 0; } void globalVarFunc() { printf("From globalVarFunc() Global a = %d ", a); printf("From globalVarFunc() Global b = %d ", b); } void localVar() { int a = 5; printf("Inside localVar() a = %d ", a); } void useStaticLocal() { static int x = 50; printf(" local static x is %d on entering useStaticLocal ", x); ++x; printf("local static x is %d on exiting useStaticLocal ", x); } void useGlobal() { printf(" global b is %d on entering useGlobal ", b); b *= 10; printf("global b is %d on exiting useGlobal ", b); }1) Open localglobal.c a) Open your Linux Shell, compile it and run. What is the output you obtained? b) Explain what main function is doing? c) How many functions main function is calling? Name them. d) Explain what happened with each of the global and local variables the first time main function called all these functions from main? e) Explain what happened with each of the the global and local variables after the second time main function called all these functions from main? f) What is the final value of a and b after running the program? (the last two printf from main function)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
