C Programming - Declarations and Initializations - Discussion
Discussion Forum : Declarations and Initializations - Yes / No Questions (Q.No. 2)
2.
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?
Discussion:
46 comments Page 4 of 5.
Sai Naveen said:
7 years ago
Here we can declare the variable name f1 globally, so it can be used anywhere in the program.
(3)
Sajla said:
1 decade ago
We can able to call the file by using extern keyword only because the file is external file.
VIJAY said:
1 decade ago
We must use extern because we access the value from the external file F1, So we use extern.
Makadiya dhara said:
1 decade ago
Without extern keyword we can not access the variable with in outside file to another file.
Rajvi said:
1 decade ago
Here, we have to declare variable globally. So both f2 & f3 can use that varible.
Supriya said:
1 decade ago
Yes we need to specify the extern because we are taking the data from the other file.
Praveen IIIT said:
1 decade ago
Yes, If you want access Programs in other files, you must declare a extern keyword.
Amandeep said:
10 years ago
As variable are used in file f2 and f3. So extern should be used for references.
Krishna said:
1 decade ago
How to include F1 file's variable in the other Files... With syntax... thanks
Pooja said:
7 years ago
Yes, but we have to declare that variable globally in f1 file also.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers