with the use of switches, draw a flowchart and algorithm that will determine and print out the sum of all even and odd integer numbers from 1 to 20. note that the sum of even integer number for the given range would be equal to the sum of 2,4,6,8,10,12,14, 16, 18, 20 and for odd integer number it would be 1, 3, 5, 7, 9, 11, 13, 15, 17, 19.
Start
Declare variable sumEven
Declare variable sumOdd
sumEven = 0
sumOdd = 0
for number = 1 to 20 do
switch(number)
number mod 2 = 0:
sumEven = sumEven + number
number mod 2 = 1:
sumOdd = sumOdd + number
end if
end for
Display sumEven
Display sumOd
Stop
Comments
Leave a comment