Embedded C interview question
Write an iterative functionAnswer
Repetition of a sequence of instructions is called iterative; this is fundamental part of many algorithms. Iteration is characterized by a set of initial conditions, an iterative step and a termination condition.Eg: new_x = n/2;
do
{
x = new_x;
new_x = 0.5 * (x + n/x);
} while (abs(new_x-x) > epsilon);
No comments:
Post a comment