SlideShare a Scribd company logo
01 #include<stdio.h>
02 #include<conio.h>
03 #include<math.h>
04 float fun(float x, float y)
05 {
06     return(0.1*x*x+0.1*y*y);
07 }
08 void main()
09 {
10     int i,j,N;
11     float x0,y0,x,h,y,k[20][20],Y[20],n,p,a;
12     clrscr();
13
14
15     printf("n Enter the initial value of X:");
16     scanf("%f",&x0);
17     printf("n Enter the initial value of Y:");
18     scanf("%f",&y0);
19     printf("n Enter the given value of X:");
20     scanf("%f",&x);
21     printf("n Enter the value of step size h:");
22     scanf("%f",&h);
23     n=(x-x0)/h;
24         N=(int)n;
25     printf("nNumber of iterations is:%dn",N);
26
27     for(i=1;i<=N;i++)
28     {
29         k[i][1]=h*fun(x0,y0);
30         k[i][2]=h*fun(x0+0.5*h,y0+0.5*k[i][1]);
31         k[i][3]=h*fun(x0+0.5*h,y0+0.5*k[i][2]);
32         k[i][4]=h*fun(x0+h,y0+k[i][3]);
33         k[i][5]=(1.0/6.0)*(k[i][1]+2*k[i][2]+2*k[i][3]+k[i][4]);
34         x0=x0+h;
35         y=y0+k[i][5];
36         Y[i]=y;
37         y0=y;
38     }
39
40     printf("nk1ttk2ttk3ttk4ttkttYn");
41     x0=x0-n*h;
42     p=h;
43
44     for(i=1;i<=N;i++)
45     {
46            for(j=1;j<=5;j++)
47            {
48                            printf("%ft",k[i][j]);
49            }
50            a=x0+h;
51            printf("tY(%f)=%f",a,Y[i]);
52            printf("n");
53            h=h+p;
54     }
55
56
57     printf("nThe final value of Y:t%f",y);
58
59     getch();
60 }

More Related Content

DOCX
1 (1)
PPT
C programs pbq final
DOCX
Euler method in c
DOCX
2 d rotation
PPTX
C programming BY Mazedur
PDF
Eso3 tablasestadisticas blog
1 (1)
C programs pbq final
Euler method in c
2 d rotation
C programming BY Mazedur
Eso3 tablasestadisticas blog

What's hot (15)

DOC
Add digits of number in c
PPTX
PROYECTO PEDRO
PDF
ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน
DOCX
Program for pyramid
PDF
Eso3 tablasestadisticas blog
DOCX
[程式設計]判斷閏年
PDF
Advanced
PPTX
Logic development
PPT
Clojure lang
PDF
Programa expresiones regulares
Add digits of number in c
PROYECTO PEDRO
ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน
Program for pyramid
Eso3 tablasestadisticas blog
[程式設計]判斷閏年
Advanced
Logic development
Clojure lang
Programa expresiones regulares
Ad

Similar to Runge kutta C programme (20)

PDF
DOCX
C lab manaual
PDF
VTU Data Structures Lab Manual
DOCX
Graphics point clipping c program
DOCX
ADA FILE
DOC
Numerical Methods in C
DOC
Daapracticals 111105084852-phpapp02
DOCX
DAA Lab File C Programs
PDF
Assignment on Numerical Method C Code
TXT
Dvst
PDF
Cpd lecture im 207
DOCX
Cg my own programs
DOCX
PPT
Struct examples
PPTX
C Programming Language Part 8
PDF
C Prog - Pointers
DOC
C basics
PDF
C programms
PPTX
LAB PROGRAMS SARASWATHI RAMALINGAM
C lab manaual
VTU Data Structures Lab Manual
Graphics point clipping c program
ADA FILE
Numerical Methods in C
Daapracticals 111105084852-phpapp02
DAA Lab File C Programs
Assignment on Numerical Method C Code
Dvst
Cpd lecture im 207
Cg my own programs
Struct examples
C Programming Language Part 8
C Prog - Pointers
C basics
C programms
LAB PROGRAMS SARASWATHI RAMALINGAM
Ad

Runge kutta C programme

  • 1. 01 #include<stdio.h> 02 #include<conio.h> 03 #include<math.h> 04 float fun(float x, float y) 05 { 06 return(0.1*x*x+0.1*y*y); 07 } 08 void main() 09 { 10 int i,j,N; 11 float x0,y0,x,h,y,k[20][20],Y[20],n,p,a; 12 clrscr(); 13 14 15 printf("n Enter the initial value of X:"); 16 scanf("%f",&x0); 17 printf("n Enter the initial value of Y:"); 18 scanf("%f",&y0); 19 printf("n Enter the given value of X:"); 20 scanf("%f",&x); 21 printf("n Enter the value of step size h:"); 22 scanf("%f",&h); 23 n=(x-x0)/h; 24 N=(int)n; 25 printf("nNumber of iterations is:%dn",N); 26 27 for(i=1;i<=N;i++) 28 { 29 k[i][1]=h*fun(x0,y0); 30 k[i][2]=h*fun(x0+0.5*h,y0+0.5*k[i][1]); 31 k[i][3]=h*fun(x0+0.5*h,y0+0.5*k[i][2]); 32 k[i][4]=h*fun(x0+h,y0+k[i][3]); 33 k[i][5]=(1.0/6.0)*(k[i][1]+2*k[i][2]+2*k[i][3]+k[i][4]); 34 x0=x0+h; 35 y=y0+k[i][5]; 36 Y[i]=y; 37 y0=y; 38 } 39 40 printf("nk1ttk2ttk3ttk4ttkttYn");
  • 2. 41 x0=x0-n*h; 42 p=h; 43 44 for(i=1;i<=N;i++) 45 { 46 for(j=1;j<=5;j++) 47 { 48 printf("%ft",k[i][j]); 49 } 50 a=x0+h; 51 printf("tY(%f)=%f",a,Y[i]); 52 printf("n"); 53 h=h+p; 54 } 55 56 57 printf("nThe final value of Y:t%f",y); 58 59 getch(); 60 }