Sabtu, 26 Oktober 2013

Komputasi Numerik : Metode Riemann

Script :

#include <conio.h>
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
float funct(float a);

int main()
{
char pilihan = 'y';
float f,x,h,a,b,sum;
do{
system("cls");
cout<<":::::::::::::::::::::::::::::::::::::::::::\n";
cout<<":: Mencari Luas dengan Integrasi Reimann ::\n";
cout<<":::::::::::::::::::::::::::::::::::::::::::\n\n";
cout<<":: Fungsi : sin(3x+10)+cos(3x+10)\n\n";
cout<<"Masukkan a (batas bawah) : "; cin>>a;
cout<<"Masukkan b (batas atas) :";cin>>b;
float i;
printf ("\t\t(x)       ||  f(x)\n");
for (i=0; i<=1; i+=0.01){
printf("\t\t%f  ||  %f\n", i,funct(i));
}
sum = 0;
x=a;
h=0.01;
while(x<b)
{
sum+=funct(x);
x=x+h;
}
cout<<endl<<"Luas : "<<sum*h<<endl;
cout<<endl<<"Apakah ingin mengulang ? (y/n)?"; cin>>pilihan;
}while(pilihan=='y');
getch();
return 0;
}

float funct(float x){
return (sin(3*x+10)+cos(3*x+10));
}

Hasil :




0 komentar:

:a: :b: :c: :d: :e: :f: :g: :h: :i: :j: :k: :l: :m: :n:

Posting Komentar