Home » Technical Questions » Programming

What would be the output of the following program? main() { extern int fun ( float ); int a; a = fun ( 3. 14 ); printf ("%d", a); } int fun ( aa ) float aa ; { return ( (int) aa ); }

Correct Answer: Error occurs because we have mixed the ANSI prototype with K & R style of function definition When we use ANSI prototype for a function and pass a float to the function it is promoted to a double When the function accepts this double into a float a type mismatch occurs hence the error The remedy for this error could be to define the function as : int fun (float aa) { }

← Previous Question Next Question→

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion