Machine-translated by Google. Questions are authored in English.
Top

Declarations and Initializations Questions and Answers

31.

Global variable are available to all functions. Does there exist a mechanism by way of which it available to some and not to others.

Answer: B

Correct answer: No

A name with external linkage is visible to every function that declares it, and nothing distinguishes one function from another. What can be restricted is the file: declaring the variable static at file scope confines it to that translation unit. The granularity is the file, not the function.

Please log in or register to report this question.

32.

Is it true that a global variable may have several declarations, but only one definition?

Answer: A

Correct answer: Yes

Every file using a global variable declares it, so a program may contain many declarations of one object. The storage is reserved once, by the single definition, and the linker resolves every declaration to it. More than one definition is an error at link time.

Please log in or register to report this question.

33.

Is it true that a function may have several declarations, but only one definition?

Answer: A

Correct answer: Yes

A prototype may appear in every file that calls the function, and usually does by way of a header, but the body is written once. The rule is the same as for objects: declarations may be repeated, and the definition may not.

Please log in or register to report this question.

Loading…

Other Subjects

Tags: Declarations and Initializations Questions and Answers || Declarations and Initializations MCQ Questions and Answers || Declarations and Initializations GK Questions and Answers || Declarations and Initializations GK MCQ Questions || Declarations and Initializations Multiple Choice Questions and Answers || Declarations and Initializations GK || GK on Declarations and Initializations || C Programming Questions and Answers || C Programming MCQ Questions and Answers || C Programming GK Questions and Answers || GK on C Programming