Answer to Question #246018 in Algorithms for jess

Question #246018

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.


1
Expert's answer
2021-10-03T11:46:00-0400
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





Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS