borjois

WELCOME TO MY BLOG

Ketik yg Anda Cari

Powered By Blogger

26/06/10

Metode Tabel CPP

METODE TABEL
Berikut adalah Source Code untuk membuat aplikasi Metode Tabel menggunakan Bahasa C++

#include
#include
#define maks 100
void main()
{
double b_ats, b_bwh, h, N;
int i;
double x[maks], y[maks];
char back;

printf(" METODE TABEL\n");


do
{
printf("\n Input Nilai Batas Bawah : ");
scanf("%lf",&b_bwh);
printf(" Input Nilai Batas Atas : ");
scanf("%lf",&b_ats);
printf(" Input Jumlah Iterasi : ");
scanf("%lf",&N);

h=(b_ats-b_bwh)/N;
for(i=0;i<=N;i++){

x[i] = b_bwh+i*h;
y[i] = x[i]+exp(x[i]);

printf("\n");
printf(" f(%.2f) = %f\n",x[i],y[i]);
}
printf("\n ........................\n");

for(i=0;i<=N-1;i++)
{
if(y[i]==0)
{

printf("\n Akar Persamaan: %lg",x[i]);
printf("\n Error : %lg\n",fabs(x[i]+exp(x[i])));
}
else if(y[i]*y[i+1]<0)
{
printf("\n Akar Persamaan : %lg",x[i]);
printf("\n Error : %lg\n",fabs(x[i]+exp(x[i])));
}
}

printf(" -Azizul Hakim Prabowo-");
printf("\n**********************************************

**********************************");
printf(" Ingin Melakukan Perhitungan kembali (Y/T) ? ");
fflush(stdin);
scanf("%s",&back);
printf("************************************************

********************************\n");printf("\n");
}
while(back=='Y'||back=='y');
}

Tidak ada komentar:

Posting Komentar

traffic