answersLogoWhite

0


Best Answer

using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { double a, b, c, dis,root1,root2,temp; Console.WriteLine("Enter the value of Cofficients "); Console.WriteLine("Enter the value of Cofficient a "); a = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter the value of Cofficient b"); b = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter the value of Cofficient c"); c = Convert.ToInt32(Console.ReadLine()); dis = b * b - 4 * a * c; Console.WriteLine("Dis is {0} ", dis); if (dis > 0) { temp = Math.Sqrt(dis); root1 = (-b + temp) / 2 * a; root2 = (-b - temp) / 2 * a; Console.WriteLine("First Root is {0} ",root1); Console.WriteLine("Second Root is {0} ",root2); } if (dis == 0) { root1 = -b / 2 * a; Console.WriteLine(" Root is {0} ", root1); } if (dis < 0) { temp = dis; root1 = -b ; root2 = 2 * a; Console.WriteLine("First Root is ({0} + ({1}i))/{2} ", root1,temp,root2); Console.WriteLine("Second Root is ({0} - ({1}i))/{2} ", root1, temp, root2); } Console.ReadLine(); } } }

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Explain briefly algorithm and draw the flow chart to find roots of a quadratic equation?
Write your answer...
Submit
Still have questions?
magnify glass
imp