132k views
5 votes
What are the values of A[K] and A[K+1] after code correspopnding to the following pseudocode is run?

A[K] = 10;
A[K+1] = 20;
A[K] = A[K+1];
A[K+1 ] = A[K];
Group of answer choices

A. A[K] = 20, A[K + 1] = 20

B. A[K] = 20, A[K + 1] = 10

C. A[K] = 10, A[K + 1] = 20

D. A[K] = 10, A[K + 1] = 10

1 Answer

7 votes

Answer:

After running the given pseudocode the values will be:

A. A[K] = 20, A[K + 1] = 20

Step-by-step explanation:

The given pseudocode appears to be applied on an array.

Let us look at the given pseudocode one by one

A[K] = 10;

This line of code assigns value 10 to the position A[K] in array

A[K+1] = 20;

This line of code assigns value 20 to the position A[K+1]

A[K] = A[K+1];

This line will assign the value at A[K+1] to A[K] which means value 20 will be assigned to A[K]

so after this line A[K] = 20

A[K+1 ] = A[K];

This line will assign the value in A[K] to A[K+1] as A[K+1] has the value 20 currently so

A[K+1] = 20

Hence,

After running the given pseudocode the values will be:

A. A[K] = 20, A[K + 1] = 20

User Frekster
by
7.1k points