Complete the code to check if a number is positive.
package main import "fmt" func main() { num := 5 if num [1] 0 { fmt.Println("Positive number") } }
The condition num > 0 checks if the number is positive.
Complete the code to check if a number is positive and even.
package main import "fmt" func main() { num := 4 if num > 0 { if num [1] 2 == 0 { fmt.Println("Positive even number") } } }
The modulus operator % checks if the number is divisible by 2 (even).
Fix the error in the nested if statement to check if a number is negative and odd.
package main import "fmt" func main() { num := -3 if num [1] 0 { if num%2 != 0 { fmt.Println("Negative odd number") } } }
The condition num < 0 checks if the number is negative.
Fill both blanks to check if a number is zero or positive and even.
package main import "fmt" func main() { num := 0 if num [1] 0 { if num [2] 2 == 0 { fmt.Println("Zero or positive even number") } } }
The first condition num >= 0 checks for zero or positive numbers.
The second condition num % 2 == 0 checks if the number is even.
Fill all three blanks to check if a number is negative, odd, and less than -10.
package main import "fmt" func main() { num := -15 if num [1] 0 { if num%2 [2] 0 { if num [3] -10 { fmt.Println("Negative odd number less than -10") } } } }
The first condition num < 0 checks negativity.
The second condition num % 2 != 0 checks oddness.
The third condition num <= -10 checks if the number is less than or equal to -10.