This section contains carefully selected MCQs and Previous Year Questions with explanations to help students understand concepts and prepare effectively for examinations, interviews, and competitive tests.
Q: 1The meaning of each ________is fixed. We can simply use them for its intended meaning.
Option D
In C programming, keywords are special words that have a fixed and predefined meaning, decided by the language itself. We cannot change their meaning, nor can we use them as identifiers.
| Related to Primitive Data Types | Related to Control Statement | Related to Storage Classes | Related to User-Defined Data Type | Other Purpose |
|---|---|---|---|---|
| int | if | auto | struct | const |
| char | else | static | union | sizeof |
| float | switch | register | enum | volatile |
| double | case | extern | typedef | |
| short | default | |||
| long | break | |||
| signed | continue | |||
| unsigned | goto | |||
| void | do | |||
| while | ||||
| for | ||||
| return |
Q: 2
Match the following C statements with the correct number of tokens:
| List—I (C Statements) | List—II (Number of Tokens) |
|---|---|
| (i) int a = 10; | (P) 5 |
| (ii) printf("Hi Suresh"); | (Q) 6 |
| (iii) a = b + c; | (R) 9 |
| (iv) x = y++ + --z; | (S) 8 |
Option D
Q: 3Count the number of tokens in following C statement?
printf("Suraku Academy");
Option A
| Element | Type | Token Count |
|---|---|---|
| printf | Identifier | 1 |
| ( | Separator | 1 |
| "Suraku Academy" | String | 1 |
| ) | Separator | 1 |
| ; | Separator | 1 |
So, total tokens are 5.
Q: 4Which of the following is not a valid variable name in most programming languages?
Option B
A variable is a named location in memory that is used to hold or store the value. The value of variable can be modified in the program by the instruction. The variable names must follow the rules of identifiers.
RULES FOR WRITING IDENTIFIERS:
| Variable Name | Result | Why? |
|---|---|---|
| myVariable | Valid. | Starts with a letter, follows identifier rules. |
| 123Variable | Invalid. | Variable names cannot start with digits. |
| _myVariable | Valid. | First character is underscore. Alphabets and underscore is allowed as the first character. |
Q: 5During entire program execution the value of ___________ cannot be changed.
Option B
In programming like C, we store information using variables or other fixed items. Some values need to stay the same forever during the whole program run, like math number PI, number of days in a week, or maximum speed limit etc.
A constant is a value that is fixed and cannot be changed during the execution of a program. Constants are used when we want to make sure a value remains the same throughout the program.
#include <stdio.h>
int main()
{
int age = 29;// Variable.
printf("Age : %d ", age);
age = 34; // Changing value of variable.
printf("Updated Age : %d ", age);
const float PI = 3.14;// Constant.
printf("Value of PI: %.2f ", PI);
PI = 3.1415; // Error. Cannot change a constant.
return 0;
}
Q: 6Which compiler phase receives tokenized output?
Option B
In the compilation process, the Lexical Analyzer is the first phase that reads the source program and converts it into a sequence of tokens (such as keywords, identifiers, operators, and symbols). These tokens form the tokenized output of the lexical analyzer.
The Parser (Syntax Analyzer) is the next phase of the compiler, and it receives these tokens as input. The parser checks whether the tokens follow the grammatical structure of the programming language and constructs a Parse Tree or Syntax Tree. Therefore, the compiler phase that receives the tokenized output is the Parser.
Q: 7A comment:
Option D
A comment is used to add notes or explanations within the source code to make it easier for humans to understand. Comments are ignored by the compiler, so they do not affect the execution of the program.
In C, a multi-line comment starts with /* and ends with */. Single-line comments can also be written using //.
Q: 8In context of C language, the word ‘if’ is a
Option B
In C language the if is keywords. A keyword is a reserved word that has a predefined meaning in the language and cannot be used as an identifier. The if is used for decision-making.
Q: 9The backslash constant ‘\r’ can be used for? Choose best answer.
Option C
The backslash constant \r is called the carriage return. It moves the cursor back to the beginning of the current line, without moving to a new line or erasing any existing content. This allows the next characters to overwrite the existing characters on the same line.
Q: 10Which of the following statement(s) is/are correct?
I. Keywords are those words whose meaning is already defined by Compiler.
II. Keywords cannot be used as variable name.
III. There are 32 keywords in ANSI C.
IV. C keywords are also called as reserved words.
Option D
Must Know:
| Keyword | Description |
| _Bool | Represents Boolean data type. In C, 0 (zero) is treated as false and any non-zero value is treated as true. |
| _Complex | Represents complex numbers (real + imaginary). |
| _Imaginary | Represents imaginary numbers (pure imaginary part). |
| inline | Suggests the compiler to expand the function inline to reduce call overhead. |
| restrict | A pointer qualifier that tells compiler the pointer is the only way to access data. |
Thank you so much for taking the time to read my Computer Science MCQs section carefully. Your support and interest mean a lot, and I truly appreciate you being part of this journey. Stay connected for more insights and updates! If you'd like to explore more tutorials and insights, check out my YouTube channel.
Don’t forget to subscribe and stay connected for future updates.