Question 61Asked in DSSSB TGT Computer Science (Technical), 12 Sep 2025, Shift 2 (1:00 PM)

What is the output of the given C programming code? void modify(int arr[], int n)

What is the output of the given C programming code? #include <stdio.h> void modify(int arr[], int n) { for(int i = 0; i < n; i++) arr[i] = arr[i] * 2; } int main() { int data[] = {1, 2, 3, 4}; modify(data, 4); printf("%d", data[2]); return 0; }
  1. A8
  2. B4
  3. C6
  4. D2
Show answerHide answer

Correct answer: (C) 6

Explanation

Arrays are passed as a pointer to their first element, so modify() doubles the original elements: data becomes {2, 4, 6, 8}, and data[2] = 6.

From DSSSB TGT Computer Science PYQ (Technical), 12 Sep 2025, Shift 2 (1:00 PM)

This is question 61 of DSSSB TGT Computer Science PYQ (Technical), 12 Sep 2025, Shift 2 (1:00 PM). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.