program biseksi

METODE BISEKSI

#include<iostream>
using namespace std;
int main(){
int i;
float fx,fa,fb;
float a,b;
float xbaru;
a=-1;
b=0;
for(i=0;i<10;i++)
{
fa=(a*a)-(4*a)-5;
fb=(b*b)-(4*b)-5;
if(fa*fb>0)
{
cout<<“berhenti”;
}
else
{
xbaru=(a+b)/2;
fx=xbaru*(xbaru)-(4*xbaru)-5;
if(fx*fa<0)
{
b=xbaru;
}else{
a=xbaru;
}
}
cout <<fx<<”   “<<fa<<endl;
}
return 0;
}

aaaaa1

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s


%d bloggers like this: