Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- class QuadraticEq
- {
- static void Main()
- {
- double a = double.Parse(Console.ReadLine());
- double b = double.Parse(Console.ReadLine());
- double c = double.Parse(Console.ReadLine());
- double determinant = Math.Pow(b, 2) - (4 * a * c);
- if (determinant == 0)
- {
- Console.WriteLine("There is one real root x1=x2= "+ (-b/(2*a)));
- }
- else if ( determinant > 0)
- {
- double firstRoot = (-b - Math.Sqrt(determinant)) / (2 * a);
- double secondRoot = (-b + Math.Sqrt(determinant)) / (2 * a);
- Console.WriteLine("There is two real roots x1 = " + firstRoot + ", x2 = " + secondRoot );
- }
- else
- {
- Console.WriteLine("There is no real roots.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement