Oleh admin | Jumat, 12 Juli 2019 10:49 | Komentar: 0
#include "iostream.h"
#include "conio.h"
#include "math.h"

void main ()
{          float a, b, c, d, x1, x2;
            clrscr ();
            cout << "masukkan nilai : ";
            cout << "a=";
            cin >> a;
            cout << "b=";
            cin >> b;
            cout << "c=";
            cin >> c;
            d=b*b+4*a*c;
            if ( d<0 )
                        cout << "tidak ada penyelesain, akar negatif!!" <<endl;
            else
            {          x1=(-b+sqrt (d))/(2*a);
                        x2=(-b-sqrt (d))/(2*a);
                        cout << "hasil perhitungan : ";
                        cout << "x1="<< x1 << endl;
                        cout << "x2="<< x2 << endl;
            }
            getch ();
}

Beri Komentar»

Belum ada komentar