Question
Consider the code shown below. What is the value of evaluating the expression sum-squares( add(5,2), mult(10,2) ) using applicative order? Normal order? int add(int x,
Consider the code shown below. What is the value of evaluating the expression sum-squares( add(5,2), mult(10,2) ) using applicative order? Normal order?
int add(int x, int y){ return x + y; }
int mult(int x, int y){ return x * y; }
int square(int x){ return x * x; }
int sum-squares(int x, int y){ return square(x) + square(y); }
Answer:
Consider the code shown below. What does the program print when q(p(1), 2, p(3)) is evaluated using applicative order? Normal order?
int p(int i) { printf("%d ", i); return i; }
void q(int a, int b, int c) { int total = a; printf("%d ", b); total += c; }
Answer:
Consider the program shown below. What is the result of executing this program if applicative order of evaluation is used? Normal order of evaluation is used?
int f(int x){ return 3; }
int fib(int n) { // return the nth Fibonacci number }
void main() { int m = f(fib(10000)); printf("%d", m); }
Answer:
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