Section9-ex2
This commit is contained in:
21
Section9/76-2.go
Normal file
21
Section9/76-2.go
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
Coding Exercise #2
|
||||
|
||||
Consider the following array declaration:
|
||||
nums := [...]int{30, -1, -6, 90, -6}
|
||||
|
||||
Write a Go program that counts the number of positive even numbers
|
||||
in the array.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
func main() {
|
||||
nums := [...]int{30, -1, -6, 90, -6}
|
||||
|
||||
for i := 0; i < len(nums); i++ {
|
||||
if i > 0 && i%2 {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user