Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which function definition will run correctly?

  • A.int sum(int a, int b)
       return (a + b);
  • B.int sum(int a, int b)
        {return (a + b);}
  • C.int sum(a, b)
         return (a + b);
  • D.Both (a) and (b)

Answer: B

Correct answer: int sum(int a, int b) {return (a + b);}

A function definition must have its body in braces. The forms without braces are not definitions at all. (The third also uses the old K&R parameter style but omits the type declarations that style requires.)

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.