C Programming - Functions - Discussion

Discussion Forum : Functions - True / False Questions (Q.No. 7)
7.
Names of functions in two different files linked together must be unique
True
False
Answer: Option
Explanation:

True, If two function are declared in a same name, it gives "Error: Multiple declaration of function_name())".

Discussion:
10 comments Page 1 of 1.

Abhijeet said:   6 years ago
File 1 :
#include<stdio.h>
void fun()
{
printf("File 1");
}
void main()
{
}

&

File 2 :
#include<stdio.h>
void fun()
{
printf("File 2");
}
void main()
{
extern fun();

fun();
}

Then according to me it will prefer the local defination of fun function & output will be
OUTPUT : File 2


Am I correct ?

Sumit kumar said:   7 years ago
I am not getting this clearly. Please, anyone explain it with an example code.

Prashanth said:   7 years ago
I think it is true. But how error comes? Please explain in detail.

Saksham said:   8 years ago
By function overloading, we can give same name but different signature to the functions, isn't it?

Hitesh said:   8 years ago
If two same function has different parameters it is possible. In this case, the answer is false. Please explain me how it is and true?

Nithesh s shetty said:   9 years ago
Suppose in two different functions can have a same variable name since both are independent.

Krushna said:   9 years ago
We declare it with the same name but files are different soo why it will give an error?

Polina said:   1 decade ago
What about two functions with the same names but different type or number of arguments?

Mouni said:   1 decade ago
If we consider two files f1, f2 can't we call them as f1.funname();
and f2.funname(); separately? please do explain me.

Saurav said:   1 decade ago
What if two are decleared as Static......... ?

Post your comments here:

Your comments will be displayed after verification.