Is it true that a function may have several declarations, but only one definition?
A:
Yes
B:
No
C:
D:
Answer:A
Yes, but the function declarations must be identical.
Example:
#include<stdio.h>
void Display();
void Display();
void Display();
void Display()
{
printf("Weclome to ExamAdept.com..!");
}
int main()
{
Display();
return 0;
}
//Output:
Weclome to ExamAdept.com..!
Discuss About this Question.
Is it true that a global variable may have several declarations, but only one definition?
A:
Yes
B:
No
C:
D:
Answer:A
Yes, In all the global variable declarations, you need to use the keyword extern.
Discuss About this Question.
Global variable are available to all functions. Does there exist a mechanism by way of which it available to some and not to others.
A:
Yes
B:
No
C:
D:
Answer:B
The only way this can be achieved is to define the variable locally in main() instead of defining it globally and then passing it to the functions which need it.
Discuss About this Question.
Suppose a program is divided into three files f1, f2 and f3, and a variable is defined in the file f1 but used in files f2 and f3. In such a case would we need the extern declaration for the variables in the files f2 and f3?
Discuss About this Question.