#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
float df(float x, float y)
{
return x+y;
}
int main()
{
float x0,y0,h,x,x1,y1;
cout<<"Enter the values of x0,y0,h,x"<<endl;
cin>>x0>>y0>>h>>x;
cout<<fixed;
x1=x0;
y1=y0;
while(1)
{
if(x1>x)
return 0;
y1 += h*df(x1,y1);
x1 += h;
cout<<"When x="<<setw(3)<<setprecision(1)<<x1;
cout<<"y="<<setw(4)<<setprecision(2)<<y1<<endl;
}
}
Output
Enter the values of x0,y0,h,x
0 1 .1 1
When x=0.1y=1.10
When x=0.2y=1.22
When x=0.3y=1.36
When x=0.4y=1.53
When x=0.5y=1.72
When x=0.6y=1.94
When x=0.7y=2.20
When x=0.8y=2.49
When x=0.9y=2.82
When x=1.0y=3.19
