Selasa, 30 Juni 2015

Program C++ Persamaan Kuadrat

#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;
}

1 komentar:

  1. Why Online Casinos Have the Better Luck of Black People - FBCAsino
    Why online casinos have the better 1xbet korean luck of 메리트 카지노 고객센터 black people. Read our study, to find out why. 바카라사이트

    BalasHapus