Computer Science, asked by raijanvi318, 9 hours ago

23. What will be the output of following program segment? int num [5] = {1, 2, 3, 4, 5}; int i, j; i = num [1]; j=num [2]; printf("%d, %d, %d”, i, j, num [0]); A. 1,2,3 B. 2,3,1 C. 1,2,0 D. 3,4,5​

Answers

Answered by sayak05112000
0

Answer:

B: 2,3,1

Explanation:

There are 5 elements in the array num (1,2,3,4,5)

However, the array index (or the element position) always starts from 0.

Thus, element '1' is at index 0 and element '2' is at index 1 and so on and finally element '5' is at index 4.

Thus num[1] means the element at index 1 (which is actually the 2nd element of the array) and num[2] is the element at index 2(which is the 3rd element)

Thus, i=num[1]= 2 and, j= num[2]= 3

And, num[0]= 1st element = 1

Thus on printing the output is 2,3,1 ( i , j, a[0] )

Similar questions