Seputar Pemrograman C
Semua Tentang Pemrograman Dasar C
Laman
Beranda
Tentang Blog
Kontak
Download Software
Elearning STMIK-IM
Jumat, 26 Juni 2015
Program Integrsi Numerik abm
Contoh Program C Simulasi Metode abm
#include
int i, N,d,y; float a, b, h, ABM2now, ABM2old, ABM3now, ABM3old, AB4now, AB4old, fnow, fold, fold_1, fold_2, fold_3, x; void ab_init(void) { printf("==================================\n"); printf("Nama : xxx\n"); printf("Nim : 361341xxx\n"); printf("Program : abm\n"); printf("==================================\n"); printf("Input N : "); scanf("%d",&N); printf("Input a : "); scanf("%f",&a); printf("Input b : "); scanf("%f",&b); h = (b-a) / N; ABM2now = 0.0; ABM2old = 0.0; ABM3now = 0.0; ABM3old = 0.0; AB4now = 0.0; AB4old = 0.0; fnow = 0.0; fold = 0.0; fold_1 = 0.0; fold_2 = 0.0; fold_3 = 0.0; }; void abm2_loop(void) { ABM2now = (float)( ABM2old + h*(3.0*fold - fold_1)/2.0 ); ABM2old = ABM2now; }; void abm3_loop(void) { ABM3now = (float)( ABM3old + h*(23.0*fold - 16.0*fold_1 + 5.0*fold_2)/12.0 ); ABM3old = ABM3now; }; void ab4_loop(void) { AB4now = (float)( AB4old + h*(55.0*fold - 59.0*fold_1 + 37.0*fold_2 - 9.0*fold_3)/24.0 ); AB4old = AB4now; }; void main(void) { system("cls"); ab_init(); for (i=1; i<=N; i++) { x = a + h*i; fnow = x * x; abm2_loop(); abm3_loop(); ab4_loop(); fold_3 = fold_2; fold_2 = fold_1; fold_1 = fold; fold = fnow; } printf("===================================\n"); printf("Hasil ABM2now = %f \n", ABM2now); printf("Hasil ABM3now = %f \n", ABM3now); printf("Hasil AB4now = %f \n", AB4now); getchar(); printf("\nHitung Lagi Tekan [1], Keluar Tekan [0] ? "); scanf("%d",&y); if(y) main(); else system("exit"); };
Tidak ada komentar:
Posting Komentar
Posting Lama
Beranda
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar