Seputar Pemrograman C
Semua Tentang Pemrograman Dasar C
Laman
Beranda
Tentang Blog
Kontak
Download Software
Elearning STMIK-IM
Jumat, 26 Juni 2015
Program Integrasi Numerik Simpson
Contoh Program C Simulasi Metode Simpson
#include
int i, N,y,d; float a, b, h, Snow, Sold, Sold_1, NCnow, NCold, fnow, fold, fold_1, x; void simpson_init(void) { printf("==================================\n"); printf("Nama : xxx\n"); printf("Nim : 361341xxx\n"); printf("Program : simpson\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; Snow = 0.0; Sold = 0.0; Sold_1 = 0.0; NCnow = 0.0; NCold = 0.0; fnow = 0.0; fold = 0.0; fold_1 = 0.0; }; void simpson_loop(void) { Snow = (float)( Sold_1 + h*(fnow + 4.0*fold + fold_1)/3.0 ); Sold_1 = Sold; Sold = Snow; }; void newtoncotes_loop(void) { NCnow = (float)( NCold + 3.0*h*(fold + fold_1)/2.0 ); NCold = NCnow; }; void main(void) { system("cls"); simpson_init(); for (i=1; i<=N; i++) { x = h*i; fnow = x * x; simpson_loop(); newtoncotes_loop(); fold_1 = fold; fold = fnow; } printf("==================================\n"); printf("Didapat Hasil Snow = %f \n", Snow); printf("Didapat Hasil NCnow = %f \n", NCnow); getchar(); printf("\n\n\tHitung Lagi Tekan [1], Keluar Tekan [0] ? "); scanf("%d",&y); if(y) main(); else system("exit"); };
Tidak ada komentar:
Posting Komentar
Posting Lebih Baru
Posting Lama
Beranda
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar