Knowee
Questions
Features
Study Tools

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

Question

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

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

Solution

The problem with the declarations is that in C, function overloading is not supported.

Function overloading is a feature where two or more functions can have the same name but different parameters. This feature is supported in languages like C++, but not in C.

Here, the function func is declared three times with different return types and parameters. This will cause a compilation error in C because the compiler will not be able to determine which function to call at the time of function invocation.

So, in C, each function should have a unique name to avoid such conflicts.

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); 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

Which of the following declaration is not supported by C language?Question 13Answera.String str;b.char *str;c.float str = 3e2;d.Both String str; & float str = 3e2;

What is the output of this C code?#include <stdio.h>void main(){double b = 3 % 0 * 1 - 4 / 2;printf("%lf", b);}-2Floating point Exception1None of the mentioned

What is the output of the following C code:Code#include <stdio.h>double hack_func(int *arr, int size) { int i, sum = 0; int res; for (i = 0; i < size; ++i) { sum += arr[i]; } res = (int)sum / size; return res;}int main () { int a[5] = {20, 21, 22, 23, 24}; double res; res = hack_func(a, 5 ); printf("%f", res ); return 0;}

When is the function declaration needed in C?

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.