What will be the output of the following pseudocode for arr[] = {1, 2, 3, 4,…

What will be the output of the following pseudocode for arr[] = {1, 2, 3, 4, 5}? Assume 0-based indexing and n = 5.

initialize i, n
initialize an array of size n
accept the values for the array

for i = 0 to n - 2
   arr[i] = arr[i] + arr[i + 1]
end for

print the array elements

  1. A.

    3 5 7 9 5

  2. B.

    3 5 6 7 8

  3. C.

    3 5 9 11 15

  4. D.

    error

Attempted by 169 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…