Get Started
724

Q: 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 ); }

  • Show Answer
  • Workspace

Answer :
Explanation :

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) {   .... }

The Most Comprehensive Exam Preparation Platform

Get the Examsbook Prep App Today