Program Persamaan Kuadrat dalam Bahasa C++

#include <iostream>
#include <math.h>
using namespace std;

int main() {
int a, b, c;
float D, x, x1, x2;

cout<<"Nilai a : ";cin>>a;
if(a==0)
cout<<"bukan persamaan kuadrat";
else{
cout<<"nilai b : ";cin>>b;
cout<<"nilai c : ";cin>>c;
D=(b*b)-(4*a*c);
if(D<0)
cout<<"akar-akarnya imajiner"<<endl;
else if (D==0){
x=(-b/2)*a;
cout<<"akar-akarnya kembar : "<<x;
}
else{
cout<<"akar-akarnya berbeda";
x1=(-b+(sqrt(D)))/2*a;
x2=(-b-(sqrt(D)))/2*a;
cout<<"x1 : "<<x1<<endl;
cout<<"x2 : "<<x2;
}
}
return 0;
}

Comments

Popular posts from this blog

Cara Membuat Halaman Login Hotspot Berbeda pada 1 Mikrotik

UltraISO Premium Edition v9.5.3

Arti OSAKMJ