8.1: Focus on Software Engineering: Introduction to Search Algorithms: 60250

Question
   
CodeLab is
a) an IDE (integrated development environment)
b) an AI-based intelligent tutoring system
c) an online set of interactive exercises with immediate feedback
d) software testing system

Solution
c) an online set of interactive exercises with immediate feedback

7.7: Arrays as Function Arguments: 10652


Question

Write a statement that declares a prototype for a function  printArray , which has two parameters. The first parameter is an array of element type  int and the second is an  int , the number of elements in the array. The function does not return a value.

Solution
void printArray(int [], int);

MPL Extra: Composition: 10802

Question

Assume that x is a variable that has been declared as an int and been given a value. Assume that twice is a function that receives a single integer parameter and returns twice its value. (So if you pass 7 to twice it will return 14. Thus the expression twice(7) has the value 14.

Write an expression whose value is eight times that of x without using the standard C arithmetic operators (*,+, etc.). Instead, use calls to twice to accomplish this.

In this exercise you must write this as a single expression-- you must not write any statements. Also, you may only use the twice() function-- no other functions or operators.

Solution
twice(twice(twice(x)))

MPL Extra: Composition: 10778

Question

Assume the availability of a function named  oneMore . This function receives an integer and returns one more than its parameter. So, pass  oneMore(12 ) and it will return 13. DO NOT DEFINE this function-- just assume it is available. YOUR TASK: write an expression whose value is 5 but in your expression you can only use the integer literal 0. You can not use anything with the digits 1-9 and you cannot use any arithmetic operators like +-*/. But you can use 0 and you can make calls to the function oneMore.

Solution
oneMore(oneMore(oneMore(oneMore(oneMore(0)))))