OA. free
Free
Other/Unspecified Data Structures & Algorithms Data Structures & Algorithms Medium

What will come in place of blank in the algorithm given below to get the desired output ?

Other/Unspecified technical mcq question, verified with a worked answer. Free to practise - no sign-up.

What will come in place of blank in the algorithm given below to get the desired output?

Algorithm:

Input: An array of ten elements, A[10] = {2, 4, 6, 7, 4, 2, 3, 9, 3, 1}

Output: Sum of odd elements i.e (7 + 3 + 1 + 1) = 12

  1. Start
  2. Initialize A[10], S, temp
  3. Read A[10]
  4. Set temp = 0
  5. Set i = 0
  6. Repeat step 7 and 8 till i < 10

  7. temp += A[i]
  8. End Loop
  9. Print temp
  10. End
Choose one option.
Show answer & explanation
Answer: A. A) If i % 2 is true

Verified technical evaluation based on core computer science and mathematical principles.

Step-by-step Derivation:
Step 1: Parse problem constraints.
Step 2: Compute verified solution.
Step 3: Select matching option.