Metode Scan dengan mengunakan c++

#include <iostream.h>
#include <stdio.h>
#include <conio.h>
#include <math.h>
main()
{
int i=1, k;
float x0, x1, xr, fx0, fx1, E, e=0.00001;
clrscr();
gotoxy(18,2);cout<<“########METODE NUMERIK MAS BRO###########”<<endl;
gotoxy(18,5);cout<<“|****===============================****|” <<endl;
gotoxy(18,6);cout<<“|%%%%%METODE SECANT f(x)=2x^2-5x+1?%%%%%|”<<endl;
gotoxy(18,7);cout<<“|****===============================****|” <<endl;
gotoxy(14,9);cout<< “Masukkan Nilai Awal   : “;cin>>x0;
gotoxy(14,10);cout<<“Masukkan Nilai Akhir  : “;cin>>x1;

gotoxy(7,12);cout<<“====================================================”<<endl;

gotoxy(8,13);cout<<“iterasi”;

gotoxy(18,13);cout<<“x0?”<<endl;
gotoxy(24,13);cout<<“x1?”;
gotoxy(30,13);cout<<“xr”;

gotoxy(34,13);cout<<“f(x0)”;
gotoxy(43,13);cout<<“f(x1)”;
gotoxy(50,13);cout<<“E”;

gotoxy(7,14);cout<<“====================================================”<<endl;
k=15;

do

{

fx0 = (2*(x0*x0))-(5*x0)+1;
fx1 = (2*(x1*x1))-(5*x1)+1;
xr = x1-(fx1*((x1-x0)/(fx1-fx0)));
E = fabs((xr-x1)/xr);
gotoxy(10,k);cout<<i;

gotoxy(16,k);printf(“%.3f”,x0);

gotoxy(22,k);printf(“%.3f”,x1);
gotoxy(28,k);printf(“%.3f”,xr);
gotoxy(34,k);printf(“%.3f”,fx0);
gotoxy(42,k);printf(“%.3f”,fx1);
gotoxy(50,k);printf(“%.3f”,E);
x0=x1;

x1=xr;
k++;

i++;
}

while(E>e); //

gotoxy(7,k);cout<<“=====================================================”<<endl;
gotoxy(k,23);cout<<“|=========================|”<<endl;
gotoxy(k,24);cout<<“|Nama   :  Eriko Istiawan |”<<endl;
gotoxy(k,25);cout<<“|Nim    :    11201496     |”<<endl;
gotoxy(k,26);cout<<“|=========================|”<<endl;

getch();

return 0;

}

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s