GATE Assistant

Past questions › Computer Science and Information Technology › GATE 2026 set1

GATE 2026 set1 · CS · MSQ · 1 mark · Compiler Design › Lexical Analysis

GATE 2026 set1 Computer Science and Information Technology question: Consider the following C statements: code Which of the following options is/are correct?

Consider the following C statements:

char *str1 = "Hello;    /* Statement S1 */
char *str2 = "Hello;";  /* Statement S2 */
int *str3 = "Hello";    /* Statement S3 */

Which of the following options is/are correct?

  1. (A)

    S1 and S2 have syntactic errors

  2. (B)

    S2 has a lexical error and S3 has a syntactic error

  3. (C)

    S1 has a lexical error and S3 has a semantic error

  4. (D)

    S1 has a syntactic error and S3 has a semantic error

Show answer

Official answer: C

Practise this question with exam-style marking

Discussion

No discussion yet.

Join the discussion