Kasus 3.3

Pertanyaan :

Carilah akar-akar persamaan kuadrat(Akar imajiner).

Jawaban :
 #include <iostream>
#include <math.h>


using namespace std;
int main(){
   int x1;
   int a;
   int b;
   int c;
   double disk;
   int x2;
   cout<<"Input your's= ";
   cin >> a;
   cout<<"input your's= ";
   cin >> b;
   cout<<"input your's= ";
   cin >> c;
   disk =b*b-4*a*c;
   if (disk>0)
   {
      x1 =-b/2*a;
      x2 =x1;
   }
   else
   {
      if (disk==0)
      {
         x1 =(-b+sqrt(disk))/2*a;
         x2 =(-b-sqrt(disk))/2*a;
      }
      else
      {
         cout << "Akar Imajinatier:" << endl;      }
   }

   return 0;

}


Raptor :


Share on Google Plus

About Luthfi

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment