C - Functions - Discussion

You Are Here :: Home > C > Functions - Discussion

 



Q.

Point out the error in the following code.

main()
{
int a=10;
void f();
a=f();
printf("\n %d",a);
}
void f()
{
printf("\n Hi");
}

A. trying to collect the value returned by f() in variable a. B. trying to collect the value returned by void() in variable a.
C. trying to collect the value returned by f() in variable f. D. trying to collect the value returned by f() in variable a.

Answer: Option A
Explaination:

Inspite of defining the function f() as returning void, the program is trying to collect the value returned by f() in variable a.



Discussion

Your Comments Goes here...
NameDiscussion