Consider the following C statement:
char * str1 = ”Hello”; // stmt S
char * str2 = ”Hello”; // stmt S
char * str3 = ”Hello” // stmt S
Which of the following are correct?
Solution :
The correct option is: S1 is lexical and S3 is syntax
Step-by-step Explanation:
1. Understanding Statement S1:
Let us examine the first statement:
char * str1 = ”Hello”;Notice the quotation marks used around the string "Hello". They are curly/smart quotes (”...”) rather than the standard straight ASCII double quotes ("...") required by the C programming language.
2. Understanding Statement S2:
The second statement is:
char * str2 = ”Hello”;Just like S1, S2 also uses curly quotes (”...”) instead of standard straight ASCII quotes ("..."). Consequently, it would also trigger a lexical error for the same reason. However, looking at our correct option and choices, we focus on classifying S1 and S3.
3. Understanding Statement S3:
The third statement is:
char * str3 = ”Hello”Notice that this statement does not end with a semicolon (;).
Conclusion:
S1 fails at the token level due to invalid characters (curly quotes), making it a lexical error.
S3 fails at the grammatical structure level due to a missing semicolon, making it a syntax error.
Therefore, the statement "S1 is lexical and S3 is syntax" is correct.
Completely free for students. Educators & coaching institutes get 2 months free Pro trial to create tests.
Access unlimited practice questions, detailed step-by-step solutions, and exam study materials — completely free for students.
Create and conduct professional online assessments with AI question generation, tab proctoring, and comprehensive batch management.
Prepare for GATE 2026 Civil Engineering with the latest question papers, previous year papers, detailed solutions, syllabus, exam pattern, preparation tips, mock tests, and subject-wise study material. Download GATE 2026 CE question papers with solutions in PDF format and boost your preparation for top engineering institutes and PSU recruitment.
Prepare effectively for GATE 2026 Electronics & Communication Engineering (EC) with this comprehensive Question Paper with Solutions. This resource includes detailed explanations, concept-wise solutions, previous year paper analysis, and exam-oriented practice to help aspirants strengthen core subjects like Electronic Devices, Analog Circuits, Digital Circuits, Signals & Systems, Network Theory, Control Systems, Electromagnetics, Communications, and more. Perfect for revision, self-assessment, and boosting your GATE 2026 EC preparation strategy.
Copyright © 2026 Combe Labs Private Limited. All Rights Reserved.