Курси /
C# Basics
else Keyword Practice
Write a condition to check if the number num
is even or odd. If the number is even, output "Even", otherwise "Odd".
main.cs
1. We can determine whether a number is even by verifying if its remainder, resulting from division by 2, equals zero;
2. In code the condition will be
2. In code the condition will be
x % 2 == 0
where x
is the number to be checked.
using 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
}
}
}
Все було зрозуміло?
Секція 3. Розділ 8
Зміст курсу
C# Basics
C# Basics
else Keyword Practice
Write a condition to check if the number num
is even or odd. If the number is even, output "Even", otherwise "Odd".
main.cs
1. We can determine whether a number is even by verifying if its remainder, resulting from division by 2, equals zero;
2. In code the condition will be
2. In code the condition will be
x % 2 == 0
where x
is the number to be checked.
using 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
}
}
}
Все було зрозуміло?
Секція 3. Розділ 8