Complete the code to check if a number is positive.
let num = 5; if num [1] 0 { println!("Positive number"); }
The condition num > 0 checks if the number is positive.
Complete the code to check if a number is between 1 and 10 (inclusive).
let num = 7; if num >= 1 && num [1] 10 { println!("Number is between 1 and 10"); }
The condition num <= 10 ensures the number is at most 10.
Fix the error in the nested condition to print "Valid" if x is positive and less than 100.
let x = 50; if x > 0 { if x [1] 100 { println!("Valid"); } }
The inner condition x < 100 checks if x is less than 100.
Fill both blanks to create a nested condition that prints "In range" if y is between 10 and 20 (exclusive).
let y = 15; if y [1] 10 { if y [2] 20 { println!("In range"); } }
The conditions y > 10 and y < 20 check if y is strictly between 10 and 20.
Fill all three blanks to create a nested condition that prints "Valid score" if score is between 50 and 100 (inclusive) and is even.
let score = 80; if score [1] 50 { if score [2] 100 { if score % 2 [3] 0 { println!("Valid score"); } } }
The conditions check if score is at least 50, at most 100, and even (remainder 0 when divided by 2).