int Yfunc(int a, int y, int b, int ap, int ag);
cout <<"Type in ap value in the interval: "<<endl;
cin >> ap;
cout <<"Type in ag value in the interval: "<<endl;
cin >> ag;
cout <<"Type in b value: "<<endl;
cin >> b;
cout << Yfunc(a, y, b, ap, ag) <<endl;
int Yfunc (int a, int y, int b, int ap, int ag)
for (int a = ap; a <= ag; a++)
y = a*a + b;
cout << y <<endl;
So this code, counts the value of y, wich is (a*a) + b.
A must be ap <= a <= ag
I can't find the value of z, wich is sqrt(y * a)
Please notice, it's my 2nd program. Thanks.
oh, by the way, y value prints 0 at the end? any solutions? thanks.
The real question is, in what way were the numbers wrong?
The sqrt() function expects a floating-point parameter and returns a floating-point result. Possibly this code which uses integers caused a loss of accuracy. But it's hard to say what went wrong without seeing the particular code which was used.