Question 1
What is the role of the Program Counter (PC) in the CPU?
To store the results of computations
To store the address of the next instruction to execute
To manage input and output operations
To provide temporary data storage

The IIT Madras BS Programming in C (Programming in C) Quiz 1 paper sat on 23 Feb 2025, in the January 2025 term: 16 questions for 50 marks in 120 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.
What is the role of the Program Counter (PC) in the CPU?
To store the results of computations
To store the address of the next instruction to execute
To manage input and output operations
To provide temporary data storage
Correct answer
To store the address of the next instruction to execute
What is the correct order of memory levels based on size (smallest to largest)?
Cache Memory → Registers → Main Memory → Secondary Memory
Registers → Cache Memory → Main Memory → Secondary Memory
Secondary Memory → Main Memory → Cache Memory → Registers
Main Memory → Cache Memory → Secondary Memory → Registers
Correct answer
Registers → Cache Memory → Main Memory → Secondary Memory
Which of the following operators in C have right-to-left associativity?
Correct answer
Consider the generalized computation given below:
1. R[0] ← M[0]
2. R[1] ← M[1]
3. R[2] = R[1] - R[0]
4. If R[2] != 0, set R[1] = R[1] + 2 and go back to step 3. Otherwise, go to step 5.
5. R[2] = R[0] + R[1]
6. M[2] ← R[2]
For which value of M[0] and M[1], the computation will enter into an infinite loop?
M[0] = 5, M[1] = 3
M[0] = 7, M[1] = 3
M[0] = 8, M[1] = 2
M[0] = 10, M[1] = 3
Correct answer
M[0] = 10, M[1] = 3
Subtract values from R1 until R2 is zero
Increment R1 by the sum of values from R2 to 1
Multiply R1 by R2
Divide R1 by R2
Correct answer
Increment R1 by the sum of values from R2 to 1
10
15
0
5
Correct answer
15
Correct answer
12
10
15
13
Correct answer
12
Convert the binary number 10101010 to its decimal equivalent.
170
180
160
175
Correct answer
170
Convert the hexadecimal number 0x7C5D to its equivalent decimal representation:
31835
31836
31837
31838
Correct answer
31837
25
15
30
20
Correct answer
30
Which of the following is true for an 8-bit 2's complement representation?
The rightmost bit represents the sign (0 for positive, 1 for negative).
The maximum positive number that can be represented is 127.
The minimum negative number that can be represented is -127.
There are 256 possible values that can be represented.
Correct answers
The maximum positive number that can be represented is 127.
There are 256 possible values that can be represented.
Select all the valid variable names in C:
_123Var
Test-Name
1stValue
break
max_length
Correct answers
_123Var
max_length
Consider the generalized computation given below:
1. R[0] ← M[0]
2. R[1] ← M[1]
3. R[1] = R[1] - R[0]
4. R[0] = R[0] + R[1]
5. R[1] = R[0] - R[1]
6. M[2] ← R[1]
What will be the value of M[2] at the end of computation if M[0] = 4 and M[1] = 7?
Correct answer: 4
Find the minimum number of bits required to represent an instruction set where there are 16 unique instructions, and each instruction can take at most 3 operands.
● The first operand should be able to represent 32 registers.
● The second operand should be able to represent -63 to 63 in signed magnitude form. ● The third operand is a single flag (1-bit).
Correct answer: 17
Correct answer: 17