Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

More Books

Students also viewed these Databases questions