Quiz Space

September 2024 term · Programming in C · BSCS3005

Programming in C End Term: 22 December 2024, Set QDB3 (September 2024 term)

The IIT Madras BS Programming in C (Programming in C) End Term paper sat on 22 Dec 2024, in the September 2024 term, set QDB3: 25 questions for 100 marks in 180 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.

Questions
25
Marks
100
Duration
180 min
MCQ
18
MSQ
3
Numerical
4

Updated

Official paper: IIT M DEGREE AN EXAM QDB3 22 Dec 2024 · No negative marking.

Question 1

+3 marksOne correct option

Which of the following data types will result in the least memory allocation?

  1. A

    double

  2. B

    char

  3. C

    short

  4. D

    float

Show answer

Correct answer

  • B

    char

Question 2

+3 marksOne correct option

What is the scope of a variable declared inside a function in C?

  1. A

    Global

  2. B

    Local to the function

  3. C

    Accessible only in main()

  4. D

    Accessible in all functions called by the parent function

Show answer

Correct answer

  • B

    Local to the function

Question 3

+3 marksOne correct option
  1. A

    In little-endian format, the least significant byte is stored at the highest memory address.

  2. B

    In little-endian format, the most significant byte is stored at the lowest memory address.

  3. C

    In big-endian format, the most significant byte is stored at the lowest memory address.

  4. D

    In big-endian format, the least significant byte is stored at the lowest memory address.

Show answer

Correct answer

  • C

    In big-endian format, the most significant byte is stored at the lowest memory address.

Question 4

+3 marksOne correct option

What is the key distinction between stack and heap memory in C programming?

  1. A

    Stack memory is used for storing global variables, while heap memory is used for storing local variables.

  2. B

    Stack memory is automatically managed for function calls, while heap memory requires explicit allocation and deallocation.

  3. C

    Stack memory can grow indefinitely, while heap memory has a fixed size defined at compile time.

  4. D

    There is no difference; stack and heap memory serve the same purpose in C programming.

Show answer

Correct answer

  • B

    Stack memory is automatically managed for function calls, while heap memory requires explicit allocation and deallocation.

Question 5

+4 marksOne correct option
  1. A

    10

  2. B

    20

  3. C

    0

  4. D

    Compilation error

Show answer

Correct answer

  • A

    10

Question 6

+4 marksOne correct option
  1. A

    5

  2. B

    10

  3. C

    15

  4. D

    Compilation error

Show answer

Correct answer

  • B

    10

Question 7

+4 marksOne correct option

What will be the output of the following C program?

  1. A

    10
    0

  2. B

    10
    5

  3. C

    10
    10

  4. D

    10
    Garbage Value

Show answer

Correct answer

  • C

    10
    10

Question 8

+4 marksOne correct option
  1. A

    A

  2. B

    B

  3. C

    C

  4. D

    D

Show answer

Correct answer

  • B

    B

Question 9

+4 marksOne correct option
  1. A

    10

  2. B

    20

  3. C

    30

  4. D

    40

Show answer

Correct answer

  • C

    30

Question 10

+4 marksOne correct option
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B

Question 11

+4 marksOne correct option

Choose the correct statement for fscanf() and scanf().

  1. A

    fscanf() always reads from standard input whereas scanf() specifies a stream from which to read

  2. B

    fscanf() specifies a stream from which to read whereas scanf() reads only from standard input

  3. C

    fscanf() and scanf() have no difference in their functionalities

  4. D

    fscanf() and scanf() can read from any specified stream

Show answer

Correct answer

  • B

    fscanf() specifies a stream from which to read whereas scanf() reads only from standard input

Question 12

+4 marksOne correct option
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • D

Question 13

+5 marksOne correct option
  1. A

    9

  2. B

    6

  3. C

    8

  4. D

    7

Show answer

Correct answer

  • C

    8

Question 14

+5 marksOne correct option

Consider the following code to check whether the input number is Prime or not. Consider that input is a positive integer. However, it contains a logical error.

  1. A

    7

  2. B

    12

  3. C

    25

  4. D

    27

Show answer

Correct answer

  • C

    25

Question 15

+5 marksOne correct option
  1. A

    Counts the number of odd numbers from 1 to n.

  2. B

    Counts the number of even numbers from 1 to n.

  3. C

    The sum of odd numbers from 1 to n.

  4. D

    The sum of even numbers from 1 to n.

Show answer

Correct answer

  • A

    Counts the number of odd numbers from 1 to n.

Question 16

+5 marksOne correct option
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 17

+5 marksOne correct option
  1. A

    6

  2. B

    2

  3. C

    14

  4. D

    1

Show answer

Correct answer

  • C

    14

Question 18

+5 marksOne correct option
  1. A

    25

  2. B

    11

  3. C

    27

  4. D

    36

Show answer

Correct answer

  • D

    36

Question 19

+4 marksOne or more correct options

Which of the following statement(s) is/are true regarding the “static” keyword in C?

Select all that apply.

  1. A

    A static variable inside a function retains its value between function calls.

  2. B

    A static global variable has file scope, meaning it is only accessible within the file where it is declared.

  3. C

    Static variables must be initialized at compile-time.

  4. D

    A static function can be called from other files of the same program.

Show answer

Correct answers

  • A

    A static variable inside a function retains its value between function calls.

  • B

    A static global variable has file scope, meaning it is only accessible within the file where it is declared.

Question 20

+3 marksOne or more correct options

Which of the following statements about pointers is/are true?

Select all that apply.

  1. A

    A pointer can be incremented to point to the next memory location of its type.

  2. B

    A pointer variable cannot be reassigned after initialization.

  3. C

    Dereferencing a pointer gives the value stored at the memory address it holds.

  4. D

    Dereferencing a pointer gives the memory address it holds.

Show answer

Correct answers

  • A

    A pointer can be incremented to point to the next memory location of its type.

  • C

    Dereferencing a pointer gives the value stored at the memory address it holds.

Question 21

+3 marksOne or more correct options

Which of the following statement(s) is/are true about unions in C?

Select all that apply.

  1. A

    Unions can contain members of different data types.

  2. B

    The size of a union is the sum of the sizes of all its members.

  3. C

    Unions can be nested within other unions or structures.

  4. D

    The size of a union is dynamically allocated based on the size of its members.

Show answer

Correct answers

  • A

    Unions can contain members of different data types.

  • C

    Unions can be nested within other unions or structures.

Question 22

+4 marksNumerical answer
Show answer

Correct answer: 19

Question 23

+4 marksNumerical answer

Consider the following code.

What will be the output of the program?

Show answer

Correct answer: 2

Question 24

+4 marksNumerical answer
Show answer

Correct answer: 60

Question 25

+4 marksNumerical answer
Show answer

Correct answer: 7