re: Daily Challenge #81 - Even or Odd VIEW POST

FULL DISCUSSION
 

Golang

I assumed string of numbers was an array.

package main

import "fmt"

func evenOrOdd(numbers [10]int) {
    evenSum := 0
    oddSum := 0

    for i := 0; i < len(numbers); i++ {
        check := numbers[i] % 2

        if check == 0 {
            evenSum += evenSum + numbers[i]
        } else {
            oddSum += oddSum + numbers[i]
        }
    }

    if evenSum > oddSum {
        fmt.Println("Even is greater than Odd")
    } else if evenSum < oddSum {
        fmt.Println("Odd is greater than Even")
    } else if evenSum == oddSum {
        fmt.Println("Even and Odd are the same")
    }
}

func main() {
    numbers := [10]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
    evenOrOdd(numbers)
}
code of conduct - report abuse