Concepts of Programming Languages

(Sean Pound) #1
Programming Exercises 385


  1. Write the following Java for statement in Ada:


int i, j, n = 100;
for (i = 0, j = 17; i < n; i++, j--)
sum += i * j + 3;


  1. Rewrite the C program segment of Programming Exercise 4 using if
    and goto statements in C.

  2. Rewrite the C program segment of Programming Exercise 4 in Java
    without using a switch statement.

  3. Translate the following call to Scheme’s COND to C and set the resulting
    value to y.


(COND
((> x 10) x)
((< x 5) (* 2 x))
((= x 7) (+ x 10))
)
Free download pdf