Answered step by step
Verified Expert Solution
Question
1 Approved Answer
- Construct a control flow graph for the program using basic blocks with statement numbers. procedure sqrt(real x):real real x1, x2, x3, eps, errval; begin
- Construct a control flow graph for the program using basic blocks with statement numbers.
procedure sqrt(real x):real
real x1, x2, x3, eps, errval;
begin
1. x3 = 1;
2. errval = 0.0;
3. eps = .001
4. if (x <= 0.0)
5. output ("illegal operand");
6. return errval;
7. else
8. if (x < 1)
9. x1 = x;
10. x2 = 1;
11. else
12. x1 = eps;
13. x2 = x;
14. endif
15. while ( (x2-x1) >= 2.0*eps )
16. x3 = (x1 + x2)/2.0
17. if ( (x3 * x3 - x) * (x1 * x1 - x) < 0 )
18. x2 = x3;
19. else
20. x1 = x3;
21. endif;
22. endwhile;
23. return x3;
24. endif;
25. end
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started