Исключение деление на ноль и возврат в начало программы - C#
Формулировка задачи:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace Console1
{
class Program
{
static void Main()
{
string buf;
int x;
int y;
int z;
try
{
buf = Console.ReadLine();
x = int.Parse(buf);
buf = Console.ReadLine();
y = int.Parse(buf);
z = x / y;
Console.WriteLine(z);
}
catch (DivideByZeroException)
{
Console.WriteLine("Деление на ноль");
}
}
}
}Решение задачи: «Исключение деление на ноль и возврат в начало программы»
textual
Листинг программы
for (;;)
{
Console.Write("Введите число: ");
int i = Console.ReadLine();
Console.WriteLine((i < 0) ? "i меньше нуля" : "i больше или равно нулю");
}