Question #52642

In C,which of the following variables are created at the time of a function call and destroyed when the function returns?
(a) integer variables(b) parameters to the function (c) static variables declared within the function (d) extern variable
I think that the answer (c). True or not?
Please advice for me related MCQ C web site.. Thanks a lot..
1

Expert's answer

2015-05-19T01:06:53-0400

Answer on Question# 52642, Programming, C

In C, which of the following variables are created at the time of a function call and destroyed when the function returns?

(a) integer variables

(b) parameters to the function

(c) static variables declared within the function

(d) extern variable

Answer: a

Integer variables are created at the time of a function call and destroyed when the function returns.

Parameters of the function can be described as reference, in this case memory, which set for memory can be removed in another part of program.


static int myStaticVar = 0;


Static- static variable. Life time - constant. Initialized once at the first performance of the operator, containing the definition of the variable. So, this type of variables didn't destroyed after return function.

Extern- means that the variable is defined anywhere else the program (in another file or further in the text). It is used to create variables that are available in all modules of the program in which they are declared. So, this type of variables didn't destroyed after return function.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS