Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Pesudecode base You are given an array with 20 elements. Each element contains a

ID: 666533 • Letter: P

Question

Pesudecode base

You are given an array with 20 elements. Each element contains an integer value.

Write a program in pseudo code to display a count of the number of ‘even’ numbers, and a count of the number of ‘odd’ numbers. Also display a sum of the ‘even’ numbers and a sum of the ‘odd’ numbers

Example input

15

296

8

195

6625

Example output

The number of even numbers in the array is XXX

The number of odd numbers in the array is XXX

The sum of the even numbers in the array is XXX

The sum of the odd numbers in the array is XXX

15

296

8

195

6625

Explanation / Answer

# pseuso code for even number

even_num = 0
for i = 1:length(array):
   if (array[i] % 2 == 0):
       even_num = even_num + 1;
print "The number of even numbers in the array is "+str(even_num)

# pseuso code for odd number

odd_num = 0
for i = 1:length(array):
   if (array[i] % 2 == 0):
       odd_num = odd_num + 1;
print "The number of odd numbers in the array is "+str(odd_num)

# pseuso code for sum of even number

even_num = 0
for i = 1:length(array):
   if (array[i] % 2 == 0):
       even_num = even_num + array[i];
print "The sum of even numbers in the array is "+str(even_num)


# pseuso code for sum of even number

odd_num = 0
for i = 1:length(array):
   if (array[i] % 2 == 0):
       odd_num = odd_num + array[i];
print "The number of odd numbers in the array is "+str(odd_num)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote