Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago