#include <iostream>
#include <stdio.h>
#include <math.h>
#include <conio.h>
using namespace std;
main ()
{
float A, B, C,E;
float D, x1, x2;
cout << "Nilai A = ";
cin >> A;
cout << "Nilai B = ";
cin >> B;
cout << "Nilai C = ";
cin >> C;
D = (B*B) - (4*A*C);
E = sqrt(D);
cout << "Nilai D = "<<D << endl;
cout << "Akar Dari D = "<<E << endl;
if(D > 0)
{
x1 = (-B+sqrt(D))/(2*A);
x2 = (-B-sqrt(D))/(2*A);
cout << "x1 = "<<x1 << endl;
cout << "x2 = "<<x2 << endl;
}
else if (D < 0)
{
cout << "Nilai D < 0";
}
else
{x1 = -B/2*A;
x2 = x1;
cout << "x1 = "<<x1 << endl;
cout << "x2 = "<<x2 << endl; }
getch();
}
Outputnya :
Tidak ada komentar:
Posting Komentar