- #1
Sumaya
- 29
- 0
Homework Statement
why the loop not looping ?
Homework Equations
fun1=x^3+4^2-x-1
fun2=3x^2+8x-1
The Attempt at a Solution
Code:
#include "stdafx.h"
#include<iostream>
using namespace std;
float fun1(float);
float fun2(float);
void main()
{
float a;
cin>>a;
if (fun2(a)>0)
do
{
a=a-(fun1(a)/fun2(a));
cout<<a<<endl;
}
while(fun2(a)<0.001);
}
float fun1( float a)
{
float y;
y=a*a*a+4*a*a-a-1;
return y;
}
float fun2( float b)
{
float y;
y=3*b*b+8*b-1;
return y;
}