Thursday, January 30, 2014

Euler's Method

#include<iostream.h>
#include<math.h>
float f(float x,float y)
{
    return (pow(x,2)+pow(y,2));
}

void main()
{
    float x0,y0,h,x1,y1,x;
    cout<<"\nEnter values of x0=";
    cin>>x0;
    cout<<"\nEnter values of y0=";
    cin>>y0;
    cout<<"\nEnter values of h=";
    cin>>h;
    cout<<"\nEnter values of x=";
    cin>>x;
    x1=x0; y1=y0;
    while(x1!=x)
    {

        y1+=h*f(x1,y1);
        x1+=h;
      cout<<"\n\ty("<<x1<<")="<<y1;
    }

}

No comments:

Post a Comment