Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Let the function fun be defined as (10 pts) fun( int *k) { *k +=4; return 3 * (*k) - 1; } suppose fun

1. Let the function fun be defined as (10 pts)

fun(int *k)

{

*k +=4;

return 3 * (*k) - 1; }

suppose fun is used in the program as follows

void main( ){

int i = 10, j = 10, sum1, sum2;

sum1 = (i / 2) + fun ( &i );

sum2 = fun ( &j ) + ( j / 2);}

What are the values of sum1 and sum2

a. Operands in the expressions are evaluated left to right?

b. Operands in the expressions are evaluated right to left?

2.Consider the following JavaScript Skeletal program (10 pts)

// the main program

var x;

function sub1( ) {

var x;

function sub2( ) {

}

}

function sub3 ( ) {

..

}

Assume that the execution of this program is in the following unit order:

main calls sub1

sub1 calls sub2

sub2 calls sub3

a. Assuming static scoping, in the following, which declaration of x is the correct one for reference to x

i)sub1 ii) sub2 ii) sub 3

b.Repeat part a but assume dynamic scoping.

3. Write a Scheme function get-odd-nums that accepts a list of numbers and returns a new list that contains only the odd numbers. (5 pts)

Example: (get-odd-nums ' (1 2 3 4 5 6 7 8 9 )) should return (9 7 5 3 1)

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_2

Step: 3

blur-text-image_3

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

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions

Question

please dont use chat gpt AI 1 0 4 0

Answered: 1 week ago