C code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

C code

C code that finds the zero of a function y=a.x+b (eg x such as y=0 ) without so lving the equation. The zero will be found within a precision limit eps=103. You will start from a fixed point at x=0and move xin the proper direction until abs(y)<eps.. If anyone who understands the question..Just give me some explanation

11th Oct 2018, 5:02 AM
Dhiviya Thirumavalavan
Dhiviya Thirumavalavan - avatar
2 Answers
+ 2
You should have values for a and b so you could get x directly as: x is (y-b)/a. You are asked to start x as 0 and solve for y. If the y value is equal to 0 or the absolute value of it is less than eps, you found the answer. Otherwise, you must change x by incrementing or decrementing it by 1. You pick how by selecting the change that makes the absolute value of y smaller. For a of 2 and b of 10 (y=2x+10), x is -5 when y is 0 so you would be decrementing. However, x of 0 is a valid answer as 10 (y = 2*0+10) < 103.
11th Oct 2018, 3:27 PM
John Wells
John Wells - avatar
+ 1
John Wells Thanks a lot
15th Oct 2018, 7:19 AM
Dhiviya Thirumavalavan
Dhiviya Thirumavalavan - avatar