Suppose that you are planning to pay $7000 yearly for 2 years for a car, which i
ID: 3582256 • Letter: S
Question
Explanation / Answer
// This is c code for given question.
// the given equation will be simplified into following equation
// (13*i2) + (19*i) - 1 = 0
// Steps:
// 13000*(i)*(i+1)2 = 7000*[ (1+i)2 - 1]
//=>13000*(i)*(i+1)2 = 7000*[(i)(i+2)]
//=> 13((i+1)2) = 7*(i+2)
//=> (13*i2) + (19*i) - 1 = 0
#include <stdio.h>
float funct(float i)
{
return (13*i*i) + (19*i) - 1;
}
int main()
{
float a = 0.001;
float b = 1.0;
int max_iter = 20000;
float epsilon = 0.001;
while(1)
{
float p = a + (b-a)/2;
float v = funct(p);
if(v == 0 || (b-a)/2 < epsilon)
{
printf("%s %f ","The Value of i is: ",p);
break;
}
if(funct(a)*v > 0)
{
a = p;
}
else
{
b = p;
}
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.