0

I need to display the even numbers in an array (in Psuedocode), and I am totally lost on how to do that.

This is as far as I have gotten:

Begin write_evens(in numbers As Array of Integers, in array_size As Integer)
    Declare count As Integer
    Set count ← 0
While count < size
*******I'm stuck on what to do in the loop*****
Set count ← count + 1

{edit}

Here's where I am:

Begin write_evens(in numbers As Array of Integers, in array_size As Integer)
    Declare count As Integer
    Set count ← 0
    While count < size
    If array_size % 2 == 0 
    Write array_Size
End if
    Set count ← count + 1
End
  • 2
    The pseudo-code you should write inside the loop is `if is_even(count) then print(count)`. –  Oct 17 '14 at 16:34

2 Answers2

2

Use modulo to test if the number is even. So something like: print <- if MOD(numbers[count]) == 0

Ryan E
  • 499
  • 1
  • 7
  • 17
0

Here is some pseudocode that should do as required. Let me know if you need any clarification.

function write_evens(A array of integers)
    int i = 0;
    while i < A.length
        if (i%2 == 0)
           print A[i] + " "
        i++
abalos
  • 1,301
  • 7
  • 12