Почему выводит Nan - C#
Формулировка задачи:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
int a, b, c;
Console.WriteLine("Enter a,b,c please");
a = Convert.ToInt32(Console.ReadLine());
b = Convert.ToInt32(Console.ReadLine());
c = Convert.ToInt32(Console.ReadLine());
double d = b * b - 4 * a * c;
double x1, x2;
x1 = (-b - Math.Sqrt(d)) / 2 * a;
x2 = (-b + Math.Sqrt(d)) / 2 * a;
Console.WriteLine("x1=" + x1 + "x2=" + x2 + "");
}
}
}Решение задачи: «Почему выводит Nan»
textual
Листинг программы
while (d < 0);