Quiz Space

January 2024 term · Programming in C · BSCS3005

Programming in C End Term: 28 April 2024 (January 2024 term)

The IIT Madras BS Programming in C (Programming in C) End Term paper sat on 28 Apr 2024, in the January 2024 term: 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
19
MSQ
3
Numerical
3

Updated

Official paper: IIT M DEGREE AN EXAM QDB3 28 Apr 2024 · No negative marking.

Question 1

+3 marksOne correct option

Which of the following statements about recursion in C programming is not true?

  1. A

    A recursive function calls itself.

  2. B

    Recursive functions must have a base case to prevent infinite calls.

  3. C

    The base case is optional for a recursive function.

  4. D

    Recursive functions are used to implement functions like factorial of a number.

Show answer

Correct answer

  • C

    The base case is optional for a recursive function.

Question 2

+3 marksOne correct option

Let a pointer variable ptr hold the address of another integer variable var. Which of the following statements will correctly print the value of var?

  1. A

    printf("%d", ptr);

  2. B

    printf("%d", *ptr);

  3. C

    printf("%d", ptr*);

  4. D

    printf("%d", &ptr);

Show answer

Correct answer

  • B

    printf("%d", *ptr);

Question 3

+3 marksOne correct option

Which of the following statements is not true about arrays in C?

  1. A

    An array stores a collection of elements of the same data type.

  2. B

    Array index always starts with 1.

  3. C

    Elements of an array are stored in contiguous memory locations.

  4. D

    Array name acts like a constant pointer that always points to the first element of the array.

Show answer

Correct answer

  • B

    Array index always starts with 1.

Question 4

+3 marksOne correct option

Which of the following statements is true about structures in C?

  1. A

    They can only contain variables of the same data type.

  2. B

    They always occupy a fixed size in memory regardless of members.

  3. C

    They allow grouping of variables under a single name, even with different data types.

  4. D

    They cannot be passed as arguments to functions.

Show answer

Correct answer

  • C

    They allow grouping of variables under a single name, even with different data types.

Question 5

+3 marksOne correct option

In C programming, which memory region is typically used for dynamic memory allocation?

  1. A

    Heap memory

  2. B

    Stack memory

Show answer

Correct answer

  • A

    Heap memory

Question 6

+3 marksOne correct option

Which function is used to write data to a file in C programming?

  1. A

    fwrite()

  2. B

    fput()

  3. C

    write()

  4. D

    put()

Show answer

Correct answer

  • A

    fwrite()

Question 7

+3 marksOne correct option

What does the #define directive do in C preprocessor?

  1. A

    Declares a variable with the value to initialize it.

  2. B

    Defines textual symbols which are replaced by their values before compilation.

  3. C

    Defines a function which may have parameters

  4. D

    Includes a header file.

Show answer

Correct answer

  • B

    Defines textual symbols which are replaced by their values before compilation.

Question 8

+4 marksOne correct option
  1. A

    Value of c: 200

  2. B

    Value of c: 170

  3. C

    Value of c: 0

  4. D

    Value of c: 180

Show answer

Correct answer

  • C

    Value of c: 0

Question 9

+4 marksOne correct option
  1. A

    main → diff→ sum → diff→ printf

  2. B

    main → printf → diff → diff → sum

  3. C

    main → printf → sum → diff→ diff

  4. D

    main → sum→ diff → diff→ printf

Show answer

Correct answer

  • A

    main → diff→ sum → diff→ printf

Question 10

+4 marksOne correct option
  1. A

    End Term Exam

  2. B

    Term

  3. C

    Term Exam

  4. D

    erm Exam

Show answer

Correct answer

  • D

    erm Exam

Question 11

+4 marksOne correct option
  1. A

    Length: 11
    Size: 11

  2. B

    Length: 11
    Size: 12

  3. C

    Length: 12
    Size: 11

  4. D

    Length: 12
    Size: 12

Show answer

Correct answer

  • B

    Length: 11
    Size: 12

Question 12

+4 marksOne correct option
  1. A

    4

  2. B

    5

  3. C

    6

  4. D

    2

Show answer

Correct answer

  • C

    6

Question 13

+4 marksOne correct option
  1. A

    1

  2. B

    2

  3. C

    3

  4. D

    0

Show answer

Correct answer

  • A

    1

Question 14

+5 marksOne correct option

What will be the output of the above program?

  1. A

    7 5 3 3

  2. B

    7 7 5 3

  3. C

    7 5 5 3

  4. D

    7 7 3 3

Show answer

Correct answer

  • C

    7 5 5 3

Question 15

+5 marksOne correct option
  1. A

    a = 1, b = 2
    a = 2, b = 1

  2. B

    a = 2, b = 1
    a = 1, b = 2

  3. C

    a = 1, b = 1
    a = 2, b = 2

  4. D

    a = 2, b = 2
    a = 1, b = 1

Show answer

Correct answer

  • B

    a = 2, b = 1
    a = 1, b = 2

Question 16

+5 marksOne correct option
  1. A

    1 2 1 3 3

  2. B

    1 2 2 3 3

  3. C

    1 2 2 3 2

  4. D

    1 2 3 3 2

Show answer

Correct answer

  • A

    1 2 1 3 3

Question 17

+5 marksOne correct option
  1. A

    1 2 3

  2. B

    2 3 4

  3. C

    3 4 5

  4. D

    1 3 5

Show answer

Correct answer

  • B

    2 3 4

Question 18

+5 marksOne correct option
  1. A

    Value of a: 0
    Value of a: 1
    Value of a: 2
    Value of a: 3

  2. B

    Value of a: 1
    Value of a: 2
    Value of a: 3
    Value of a: 4

  3. C

    The program will crash because the static variable “a” is not initialized.

  4. D

    Value of a: some_garbage_value
    Value of a: some_garbage_value
    Value of a: some_garbage_value
    Value of a: some_garbage_value

Show answer

Correct answer

  • A

    Value of a: 0
    Value of a: 1
    Value of a: 2
    Value of a: 3

Question 19

+5 marksOne correct option
  1. A

    epliru

  2. B

    xelams

  3. C

    expell

  4. D

    iarmus

Show answer

Correct answer

  • A

    epliru

Question 20

+3 marksOne or more correct options

Select all that apply.

  1. A

    The initialization expression is executed only once before the loop starts.

  2. B

    If the condition expression is evaluated false, then the loop terminates.

  3. C

    The loop body is always executed at least once.

  4. D

    The increment/decrement expression is executed after each iteration of the loop.

Show answer

Correct answers

  • A

    The initialization expression is executed only once before the loop starts.

  • B

    If the condition expression is evaluated false, then the loop terminates.

  • D

    The increment/decrement expression is executed after each iteration of the loop.

Question 21

+4 marksOne or more correct options

Select the correct statements from the below that dynamically allocate memory to hold 3 integer pointers. Assume size of int is 4 bytes, size of char is 1 byte and size of pointer is 8 bytes.

Select all that apply.

  1. A

    int* a = malloc(24);

  2. B

    int** a = malloc(24);

  3. C

    int* a = malloc(3*sizeof(int));

  4. D

    int** a = malloc(3*sizeof(int*));

Show answer

Correct answers

  • B

    int** a = malloc(24);

  • D

    int** a = malloc(3*sizeof(int*));

Question 22

+5 marksOne or more correct options

Select all that apply.

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

Correct answers

  • A
  • C

Question 23

+4 marksNumerical answer
Show answer

Correct answer: 11

Question 24

+4 marksNumerical answer
Show answer

Correct answer: 5

Question 25

+5 marksNumerical answer
Show answer

Correct answer: 11