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
- Start
- Initialize A[10], S, temp
- Read A[10]
- Set temp = 0
- Set i = 0
- Repeat step 7 and 8 till i < 10
- temp += A[i]
- End Loop
- Print temp
- End
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.