Question: Given 5 input numbers, the algorithm below should calculate the sum of all the even input numbers. a. Identify what is wrong with the

Given 5 input numbers, the algorithm below should calculate the sum of all the even input numbers. a. Identify what is wrong with the following algorithm. b. How should we fix it? integer i integer array (5) A integer sum i = 0 while (i < 5) A[i] = Get next input i = i + 1 i = 0 sum = 0 while(i < 5) if (A[i] % 2 = 0) sum sum + A[i] i = i + 1 Put sum to output
Step by Step Solution
There are 3 Steps involved in it
a Issues with the algorithm The loop index variable i is not initialized before the loop starts It s... View full answer
Get step-by-step solutions from verified subject matter experts
