Pada kali saya akan mencoba membuat coding menghitung rumus ABC pada C++, berikut codingnya:
#include "iostream.h"
#include "conio.h"
#include "math.h"
void main ()
{          float a, b,
c, d, x1, x2;
            clrscr ();
            cout << "masukkan nilai
:\n";
            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 :\n";
                        cout
<< "x1="<< x1 << endl;
                        cout
<< "x2="<< x2 << endl;
            }
            getch ();
}
 
0 Response to "MENGHITUNG RUMUS ABC MENGGUNAKAN C++"
Post a Comment