Here is a example of Runge-Kutta method which is written in CPP programming.Several function are use in this program.It is written in very simple way so that everyone can understand easily. If you got any error during execution time please inform us so that we can modify the bug or errors.
/* http://native-code.blogspot.com */ #include<stdio.h> #include<conio.h> floatfunc(float a,float b) { float c; c=(a*a+b); return(c); } void main() { float x,y,x0=0,y0,h,n,i,k1,k2; clrscr(); printf("\n/* http://native-code.blogspot.com */"); printf("\nEnter the value of y0:"); scanf("%f",&y0); printf("\nEnter the value of h:"); scanf("%f",&h); printf("\nEnter the value of x:"); scanf("%f",&x); n=(x-x0)/h; x=x0; y=y0; for(i=0;i<n;i++) { k1=h*func(x,y); k2=h*func(x+h,y+k1); y=y+(0.5*(k1+k2)); x=x+h; } printf("\nResult is=%.2f",y); getch(); }Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us/* http://native-code.blogspot.com */
1 comments:
good
ReplyPost a Comment