Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Rewrite the C program below using Scheme. Your Scheme code should generate the same output. #include int func ( int a , int b )

Rewrite the C program below using Scheme. Your Scheme code should generate the same output.
#include
int func(int a, int b){
return (a * a + b);
}
int main(void){
int x[]={1,2,3,4};
int y[]={3,4,9,2};
int z[4];
for (int ii=0;ii<4;ii++){
z[ii]= func(x[ii],y[ii]);
}
for (int ii=0;ii<4;ii++){
printf("%d ", z[ii]);
}
return 0;
}
Rewrite the Scheme program below using C. Your C code should generate the same output.
(define a 10)
(define b 5)
(define c (+ a b))
(define func
(lambda (c)
(if (= c 0)
'()
(cons c (func (- c 1))))))
(func a)
(func c)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions