Question: Consider the following 3 programs: 1 2 3 / / contents of file foo.c: static int a = 5 ; int main ( ) {

Consider the following 3 programs:
123
//contents of file foo.c: static int a =5; int main(){ f(); return 0; }//contents of file bar.c: static int a =10; void f(){ printf("%d
", a); }
//contents of file foo.c: int a =5; int main(){ f(); return 0; }//contents of file bar.c: extern int a; void f(){ printf("%d
", a); }
//contents of file foo.c: static int a =5; int main(){ f(); return 0; }//contents of file bar.c: int a; void main(){ printf("%d
", a); }
If the command "gcc foo.c bar.c" is executed, which of the above programs result in a linker error?
Group of answer choices
3 only
2 and 3
1 only
1,2, and 3
1 and 2
2 only

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!