GATE Assistant

Past questions › Computer Science and Information Technology › GATE 2024 set2

GATE 2024 set2 · CS · MSQ · 1 mark · Programming and Data Structures › C Programming Fundamentals

GATE 2024 set2 Computer Science and Information Technology question: Consider the following C function definition. code Which of the following statements…

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

Show answer

Official answer: A,B,D

Practise this question with exam-style marking

Discussion

No discussion yet.

Join the discussion