Вывести все четные числа из диапазона - C#
Формулировка задачи:
Вывести все парные числа, в диапазоне от числа n до числа m.
Я пытался...
int i = 0;
int n = Convert.ToInt32(textBox1.Text);
int m = Convert.ToInt32(textBox2.Text);
for (i = n; i >= m; i++)
{
if (i % 2 == 0)
{
textBox3.Text += Convert.ToString(i);Решение задачи: «Вывести все четные числа из диапазона»
textual
Листинг программы
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static void Main(string[] args)
{
Console.Write("Write number 1: ");
int n = int.Parse(Console.ReadLine());
Console.Write("Write number 2: ");
int m = int.Parse(Console.ReadLine());
for (int i = n; i <= m; i++)
{
if (i % 2 == 0)
{
Console.Write(i + " ");
}
}
Console.ReadKey();
}
}