What will be the output of the following pseudo-code for a given array…

2023

What will be the output of the following pseudo-code for a given array a[5]=3,4,6,1,2 and pos=2 [note: n= size of the array i.e. 5 and starting array index is 0]

Declare i,j,n,pos

Repeat for j=pos to n-1

Set a[j]=a[j+1] [end of loop]

n=n-1;

Display the new array

End

  1. A.

    3615

  2. B.

    34215

  3. C.

    3412

  4. D.

    324615

Attempted by 161 students.

Show answer & explanation

Correct answer: C

The following code is for deletion of an element at a specific user-defined position, in this case, the element is 6 and its position is 2

Explore the full course: Accenture Preparation