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

Discussion

What is the notation for the following functions?

1.  int f(int a, float b)
    {
        /* Some code */
    }

2.  int f(a, b)
    int a; float b;
    {
        /* Some code */
    }

 

  • A.
    1. KR Notation   2. ANSI Notation
  • B.
    1. Pre ANSI C Notation   2. KR Notation
  • C.
    1. ANSI Notation   2. KR Notation
  • D.
    1. ANSI Notation   2. Pre ANSI Notation

Answer: C

Correct answer: 1. ANSI Notation 2. KR Notation

The first form declares each parameter’s type inside the parentheses - the ANSI (prototype) style, introduced by the 1989 standard. The second lists only the names in the parentheses and declares their types between the parentheses and the body - the old Kernighan and Ritchie style. The ANSI form matters because it lets the compiler check the arguments at every call; the K&R form does not, and is now obsolete.

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

Post your comment

Please log in or register to post a comment.