Complete the code to check if a number is positive.
int number = 10; if (number [1] 0) { Console.WriteLine("Positive number"); }
The condition number > 0 checks if the number is positive.
Complete the code to check if a number is positive and even.
int number = 8; if (number > 0 && number [1] 2 == 0) { Console.WriteLine("Positive even number"); }
The modulus operator % checks the remainder. number % 2 == 0 means the number is even.
Fix the error in the nested if statement to check if a number is positive and less than 100.
int number = 50; if (number > 0) { if (number [1] 100) { Console.WriteLine("Number is positive and less than 100"); } }
The inner condition should check if number < 100 to confirm it is less than 100.
Fill both blanks to create a nested if that checks if a number is positive and divisible by 5.
int number = 25; if (number [1] 0) { if (number [2] 5 == 0) { Console.WriteLine("Positive and divisible by 5"); } }
The first condition checks if the number is greater than zero. The second uses modulus '%' to check divisibility by 5.
Fill all three blanks to create a nested if that checks if a number is negative, odd, and less than -10.
int number = -15; if (number [1] 0) { if (number [2] 2 != 0) { if (number [3] -10) { Console.WriteLine("Negative, odd, and less than -10"); } } }
The first condition checks if number is less than zero (negative). The second uses modulus '%' to check if odd (remainder not zero). The third checks if number is less than -10.