C Programming - Functions - Discussion

Discussion Forum : Functions - Find Output of Program (Q.No. 10)
10.
What will be the output of the program?
#include<stdio.h>
int fun(int, int);
typedef int (*pf) (int, int);
int proc(pf, int, int);

int main()
{
    printf("%d\n", proc(fun, 6, 6));
    return 0;
}
int fun(int a, int b)
{
   return (a==b);
}
int proc(pf p, int a, int b)
{
   return ((*p)(a, b));
}
6
1
0
-1
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
49 comments Page 3 of 5.

Pratibha said:   1 decade ago
@Ashish

Your fun() code is this here

int fun(int a)
{
return (a=9); //a is assigned to 9 not compared.
}

:)

Veer said:   1 decade ago
Simply. Return statement only returns one value i.e. rightmost value.

Amar said:   1 decade ago
Can anyone please explain me the flow of control of dis program?? :)

Prashant said:   8 years ago
@Vishwas.

Thank you, your explanation was easy to understand.

Manish Thakur said:   7 years ago
== operator upon aucces it will return 1 so one is printed.

Swathi said:   2 decades ago
Please. Can any one clearly explain this program?.

Ramya said:   1 decade ago
Please define the proc function in clear manner.

Nayana said:   1 decade ago
@Vasuroshan, thank you for your explaination.

Preethi said:   2 decades ago
What does proc mean and give me its syntax?

Vicky said:   1 decade ago
Return statement only returns one value.


Post your comments here:

Your comments will be displayed after verification.