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

How can a program be made to print the name of a source file where an error occurs?

1 Answers  


What are global variables and explain how do you declare them?

1 Answers  


What the advantages of using Unions?

1 Answers   TISL,


2. Write a function called hms_to_secs() that takes three int values—for hours, minutes, and seconds—as arguments, and returns the equivalent time in seconds.. Create a program that exercises this function by repeatedly obtaining a time value in hours, minutes, and seconds from the user (format 12:59:59), calling the function, and displaying the value of seconds it returns.

5 Answers   TCS,


Can a pointer be static?

1 Answers  


Tell me can the size of an array be declared at runtime?

1 Answers  


What is the meaning of typedef struct in c?

1 Answers  


HOW TO SWAP TWO NOS IN ONE STEP?

16 Answers   Satyam,


How can I recover the file name given an open stream?

1 Answers  


Differentiate between the expression “++a” and “a++”?

1 Answers  


Can we assign string to char pointer?

1 Answers  


. Write a program to get a string and to convert the 1st letter of it to uppercase

2 Answers   HTC,


Categories