Knowee
Questions
Features
Study Tools

What is the problem in the following C declarations? int func(int); double func(int); int func(float); A function with same name cannot have different signaturesA function with same name cannot have different return typesA function with same name cannot have different number of parametersAll of the mentioned

Question

What is the problem in the following C declarations? int func(int); double func(int); int func(float); A function with same name cannot have different signaturesA function with same name cannot have different return typesA function with same name cannot have different number of parametersAll of the mentioned

🧐 Not the exact question you are looking for?Go ask a question

Solution

The problem in the given C declarations is that a function with the same name cannot have different return types. In C, function overloading, which is a feature where two or more functions can have the same name but different parameters or return type, is not supported.

Here, the function 'func' is declared three times with different return types (int and double) and parameter types (int and float). This is not allowed in C. The compiler will throw an error because it will get confused about which function to call at the time of function invocation.

So, the correct answer is "A function with same name cannot have different return types".

This problem has been solved

Similar Questions

What is the problem in the following C declarations? int func(int); double func(int); int func(float);

8. The phenomenon of having two or more functions in a program with the samename but different numbers and types of parameters is called:A. Inline functionC. Function overloadingB.D.Nested functionRecursive function9. The dereference operator is d enoted by:A. * B. &C. ** D. &&10. Which one of the following indicates the address of a variable “temp” of typefloat?A. float temp& B. &tempC. &float temp D. temp&11. Which one of the following is the default access specifier of C++ class?A. Private B. PublicC. Protected D. Default12. Identify the header file needed to read, write, and manipulate the file:A. ifstream B. ofstreamC. istream D. fstream13. Which one of the following functions is used to write a single character to a file

When is the function declaration needed in C?

When is it possible in C++ to have two different functions with the same name?Select one:a.When their parameter types are differentb.When the parameters and the parameter types are the samec.When the parameter types or number of parameters are differentd.When the parameter types are the same but the parameters are different

With respect to  the following code:int f(int a, char b, double *p) {    return a + b + (int) *p;}int main() {    int x;    char b;    double d, *dp;    dp = &d;    x = f(x, b, dp);    return 1;}Match the pairsreturn typeAnswer 1Formal ParametersAnswer 2Parameter ProfileAnswer 3prototypeAnswer 4Actual ParametersAnswer 5Name of functionAnswer 6SignatureAnswer 7

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.