Проверка числа на четность - C#
Формулировка задачи:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int a;
Console.Write("введите число: ");
a= Console.Read();
if (a % 2==1)
{
Console.WriteLine("число нечетное");
}
else
{
Console.WriteLine("Число четное");
}
Console.ReadKey();
}
}
}Решение задачи: «Проверка числа на четность»
textual
Листинг программы
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int a;
Console.WriteLine("введите число: ");
a = Convert.ToInt32(Console.ReadLine());
if (a % 2 == 0)
{
Console.WriteLine("четное число");
}
else
{
Console.WriteLine("нечетное");
}
Console.ReadKey();
}
}
}