Desafío: Palabra Clave Else
Write a condition to check if the number num is even or odd. If the number is even, output "Even", otherwise "Odd".
main.cs
12345678910111213141516using System; namespace ConsoleApp { class Program { static void Main(string[] args) { int num = 5; // Write code below this line // Write code above this line } } }
- We can determine whether a number is even by verifying if its remainder, resulting from division by
2, equals zero. - In code the condition will be
x % 2 == 0wherexis the number to be checked.
main.cs
1234567891011121314151617181920212223using System; namespace ConsoleApp { class Program { static void Main(string[] args) { int num = 5; // Write code below this line if (num % 2 == 0) { Console.WriteLine("Even"); } else { Console.WriteLine("Odd"); } // Write code above this line } } }
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 3. Capítulo 8
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla
Awesome!
Completion rate improved to 1.59
Desafío: Palabra Clave Else
Desliza para mostrar el menú
Write a condition to check if the number num is even or odd. If the number is even, output "Even", otherwise "Odd".
main.cs
12345678910111213141516using System; namespace ConsoleApp { class Program { static void Main(string[] args) { int num = 5; // Write code below this line // Write code above this line } } }
- We can determine whether a number is even by verifying if its remainder, resulting from division by
2, equals zero. - In code the condition will be
x % 2 == 0wherexis the number to be checked.
main.cs
1234567891011121314151617181920212223using System; namespace ConsoleApp { class Program { static void Main(string[] args) { int num = 5; // Write code below this line if (num % 2 == 0) { Console.WriteLine("Even"); } else { Console.WriteLine("Odd"); } // Write code above this line } } }
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 3. Capítulo 8