akar2.cpp

Bookmark and Share
#include<iostream.h>

#include<math.h>

int main   ()

{

    long a,b,c,d,e,f,x1,x2;

    cout<<"AKAR-AKAR PERSAMAAN FUNGSI KUADRAT\n";

    cout<<"       2\n";

    cout<<"f(x)=ax + bx +c\n";

    cout<<"\na = ";cin>>a;

    cout<<"\nb = ";cin>>b;

    cout<<"\nc = ";cin>>c;

    d=(b*b)-(4*a*c);

if(d>=0){

    e=sqrt(d);

    f=(2*a);

    x1=((-b+e)/(f));

    x2=((-b-e)/(f));

    cout<<"\nAkar-akarnya adalah x1 = "<<x1 <<" dan x2 = "<<x2;}

    else

    cout<<"\nAkar-akarnya imajiner.";

    return 0;

}

{ 0 komentar... Views All / Send Comment! }

Posting Komentar

Powered By Blogger