uiz Space

September 2023 term · Programming in C · BSCS3005

Programming in C Quiz 1: 29 October 2023 (September 2023 term)

The IIT Madras BS Programming in C (Programming in C) Quiz 1 paper sat on 29 Oct 2023, in the September 2023 term: 18 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.

Questions
18
Marks
50
Duration
120 min
MSQ
3
MCQ
13
Numerical
2

Updated

Official paper: IIT M DEGREE AN2 EXAM QPE2 29 Oct 2023 · No negative marking.

Question 1

+2 marksOne or more correct options

Which of the following is/are false statement(s) regarding C programming language?

Select all that apply.

  1. A

    It is an imperative programming language.

  2. B

    It is not a structured programming language.

  3. C

    It is a dynamically typed programming language.

  4. D

    The language uses curly braces ({ }) to define the scope of a for loop.

Show answer

Correct answers

  • B

    It is not a structured programming language.

  • C

    It is a dynamically typed programming language.

Question 2

+2 marksOne or more correct options

Which of the following statement(s) is/are true regarding ASCII and Unicode?

Select all that apply.

  1. A

    Unicode is a character set.

  2. B

    ASCII uses 6 bits to encode a given character.

  3. C

    UTF-16 and UTF-32 are both variable length encoding techniques.

  4. D

    UTF-8 is a fixed length encoding technique.

Show answer

Correct answers

  • A

    Unicode is a character set.

  • C

    UTF-16 and UTF-32 are both variable length encoding techniques.

Question 3

+2 marksOne or more correct options

Which of the following is/are valid identifiers in C language?

Select all that apply.

  1. A

    123var

  2. B

    _myVar

  3. C

    my-var

  4. D

    Var_123

  5. E

    myVar!

Show answer

Correct answers

  • B

    _myVar

  • D

    Var_123

Question 4

+2 marksOne correct option

In split memory architecture, what is the purpose of cache memory?

  1. A

    To store the operating system

  2. B

    To provide the permanent storage

  3. C

    To temporarily store frequently used data for fast access

  4. D

    To control the input/output devices

Show answer

Correct answer

  • C

    To temporarily store frequently used data for fast access

Question 5

+2 marksOne correct option

What is the primary function of the Program Counter in a CPU?

  1. A

    Execute arithmetic operations

  2. B

    Keep track of the currently executing instruction

  3. C

    To control the input/output devices

  4. D

    Manage memory access

Show answer

Correct answer

  • B

    Keep track of the currently executing instruction

Question 6

+2 marksOne correct option

Suppose you have a document which contains 58 unique characters. What is the minimum number of bits required to encode a single character in this document?

  1. A

    2⁶

  2. B

    6

  3. C

    2⁷

  4. D

    7

Show answer

Correct answer

  • B

    6

Question 7

+2 marksOne correct option

Consider the following equation:

If all the variables are float, which of the following is a correct way to write the given equation in C language?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • D

Question 8

+4 marksOne correct option

Consider the following steps to compute the minimum among three numbers. Load the three numbers from memory locations M[0], M[1] and M[2] and store the maximum number in M[3].

Identify the appropriate instructions to fill the blank at step 4 and step 6.

  1. A

    Step 4: If R[0] < R[1] then go to step 5, otherwise go to step 6
    Step 6: If R[1] < R[2] then go to step 7, otherwise go to step 8

  2. B

    Step 4: If R[0] > R[1] then go to step 5, otherwise go to step 6
    Step 6: If R[1] < R[2] then go to step 7, otherwise go to step 8

  3. C

    Step 4: If R[0] < R[1] then go to step 5, otherwise go to step 6
    Step 6: If R[1] > R[2] then go to step 7, otherwise go to step 8

  4. D

    Step 4: If R[0] > R[1] then go to step 5, otherwise go to step 6
    Step 6: If R[1] > R[2] then go to step 7, otherwise go to step 8

Show answer

Correct answer

  • A

    Step 4: If R[0] < R[1] then go to step 5, otherwise go to step 6
    Step 6: If R[1] < R[2] then go to step 7, otherwise go to step 8

Question 9

+4 marksOne correct option

Consider the below C program.

The above C program is used to calculate the sum of individual digits of a number. For ex: If the value given to the variable “n” is 25, the sum of individual digits will be 7.
Fill in the placeholders “Expression1” and “Expression2” to ensure that the program functions correctly.

  1. A

    Expression1: r = n % 10;
    Expression2: n = r;

  2. B

    Expression1: r = n / 10;
    Expression2: n = n % 10;

  3. C

    Expression1: r = n % 10;
    Expression2: n = n / 10;

  4. D

    Expression1: n = n % 10;
    Expression2: r = n;

Show answer

Correct answer

  • C

    Expression1: r = n % 10;
    Expression2: n = n / 10;

Question 10

+3 marksOne correct option

Compute the 9-bit binary representation of the decimal number 468.

  1. A

    011101010

  2. B

    111010100

  3. C

    011101001

  4. D

    111010010

Show answer

Correct answer

  • B

    111010100

Question 11

+3 marksOne correct option

Find the 8-bit binary representation of (− 50)10 using 2’s complement notation.

  1. A

    (11001111)2

  2. B

    (11000111)2

  3. C

    (11000110)2

  4. D

    (11001110)2

Show answer

Correct answer

  • D

    (11001110)2

Question 12

+3 marksOne correct option

(764)10 = (________)8
Identify the appropriate option to fill in the above blank.

  1. A

    1271

  2. B

    1364

  3. C

    1374

  4. D

    1274

Show answer

Correct answer

  • C

    1374

Question 13

+3 marksOne correct option

Given two integer variables, x and y, which of the following expressions ensures that both x and y are distinct positive integers if the expression returns 1?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • D

Question 14

+3 marksOne correct option

Consider the following code snippet.

What will be the value of x, y and z after executing the given code snippet?

  1. A

    x = 2, y = 4, z = 1

  2. B

    x = 2, y = 4, z = 0

  3. C

    x = 2, y = 3, z = 1

  4. D

    x = 2, y = 3, z = 0

Show answer

Correct answer

  • D

    x = 2, y = 3, z = 0

Question 15

+3 marksOne correct option

Consider the below C program.

What will be the output of above given code?

  1. A

    Equal

  2. B

    Not Equal

  3. C

    Compilation error

  4. D

    Runtime error

Show answer

Correct answer

  • A

    Equal

Question 16

+3 marksOne correct option

Consider the below C program.

What would be the output of the given code?

  1. A

    8

  2. B

    3

  3. C

    0

  4. D

    4

Show answer

Correct answer

  • C

    0

Question 17

+3 marksNumerical answer

Consider the following assembly program (assume anything after “;” is a comment).

What will be the final value stored in register R2?
Note: The answer input must be an integer. For Ex: If the answer is 32, you must enter 32 only.

Show answer

Correct answer: 30

Question 18

+4 marksNumerical answer

Consider the below C program.

What would be the output of the given code?
Note: The answer input must be an integer. For Ex: If the answer is 32, you must enter 32 only.

Show answer

Correct answer: 120