in one file global variable int i; is declared as static. In
another file it is extern int i=100;
Is this valid ?

Answers were Sorted based on User's Feedback



in one file global variable int i; is declared as static. In another file it is extern int i=100; ..

Answer / vadivel t

No. it is not valid,

Bcos we can not initialise a variable with an extern key
word.ie.,

The statement extern int i = 100; is wrong.

Is This Answer Correct ?    14 Yes 5 No

in one file global variable int i; is declared as static. In another file it is extern int i=100; ..

Answer / dipti

No its in valid as a static variable cannot be declared as extern.
The whole and entire purpose of static is to declare that a variable is private to the source file that it is declared in.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

differentiate between const char *a; char *const a; and char const *a;

2 Answers   College School Exams Tests, HCL, TCS,


how to reverse string "Hello World" by using pointers only. Without any temp var

1 Answers  


main() { int i; for(i=0;i<5;i++) printf("%d",1l<<i); } why doesn't 'l' affect the code??????

1 Answers  


the format specified for hexa decimal is a.%d b.%o c.%x d.%u

7 Answers   TCS,


How we can set and clear bit in a byte using macro function?

2 Answers   L&T, Samsung,






can we implement multi-threads in c.

0 Answers  


Explain what header files do I need in order to define the standard library functions I use?

0 Answers  


What is the difference between ‘g’ and “g” in C?

1 Answers  


What's the best way of making my program efficient?

0 Answers   Celstream,


What is volatile keyword in c?

0 Answers  


What is c programming structure?

0 Answers  


What does *p++ do? What does it point to?

0 Answers  


Categories