Skip to content
GATEiit

GATE CSE 2026 Session 1 Q27: Classify errors in three C string declarations

Question

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?

Try it: multiple select: one or more correct options

Select one or more options
Select all correct options. No negative marking, no partial marks.
Show answer and explanation

Answer: C (official GATE 2026 final answer key)

Concept used: Lexical errors are bad tokens (e.g. an unterminated string literal); type mismatches are semantic errors.

First step: S1's string literal never closes, so the lexer cannot form a token; S2 is valid; S3 assigns a char* to an int*.

Full step-by-step solution

Detailed working, common mistakes and linked mock tests will be available with a free GATEiit account. Log-in is coming soon.

Share this question

WhatsAppDownload image

Source: official GATE 2026 Session 1 CS question paper and final answer key, organised by IIT Guwahati. Question paper · Answer key