← All examples

Quadratic discriminant

C# Branching

if / else if / else

Flowchart (ISO 5807)

YesNoYesNoStartInput a, b, cd = b * b - 4 * a * cd > 0Output «два корені»d == 0Output «один корінь»Output «немає коренів»EndFigure 1 — Program.SolveQuadratic

Source code

class Program {
    static void SolveQuadratic(double a, double b, double c) {
        double d = b * b - 4 * a * c;
        if (d > 0) {
            System.Console.WriteLine("два корені");
        } else if (d == 0) {
            System.Console.WriteLine("один корінь");
        } else {
            System.Console.WriteLine("немає коренів");
        }
    }
}