GATE CS 2024, set 2 · Question 33 · Programming and Data Structures · Multiple select (MSQ) · 1 mark · no negative marks

Consider the following C function definition.
int fX(char *a){ char *b = a; while(*b) b++; return b - a;}
Which of the following statements is/are TRUE?

  1. (A) The function call fX("abcd") will always return a value
  2. (B) Assuming a character array c is declared as char c[] = "abcd" in main(), the function call fX(c) will always return a value
  3. (C) The code of the function will not compile
  4. (D) Assuming a character pointer c is declared as char *c = "abcd" in main(), the function call fX(c) will always return a value
Answer

Answer (A), (B), (D)

Answer from the official GATE CS 2024 answer key.

The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes