Write a statement  that assigns  x the value  k*(k-1)*(k-2)*…*3*2*1 by calling the fact function and multiplying its return value  by k.

C++

LANGUAGE: C++ CHALLENGE: Assume  the availability of a function called fact. The function receives an int argument  and returns an int value . If the argument  is one or smaller, it returns the integer  value  one. Otherwise it returns the product  of all the integers  from one to its argument . So the value  of fact(4) is 1*2*3*4 and…

Read More

The elements of an integer -valued array can be set to 0 (i.e., the array can be cleared) recursively as follows: An array of size 0 is already cleared; Otherwise, set the first element of the array to 0, and clear the rest of the array Write a void function named clear that accepts an integer array, and the number of elements in the array and sets the elements of the array to 0.

C++

LANGUAGE: C++ CHALLENGE: The elements  of an integer -valued  array  can be set to 0 (i.e., the array  can be cleared) recursively as follows: An array  of size 0 is already  cleared; Otherwise, set the first element  of the array  to 0, and clear the rest of the array  Write a void function named  clear that…

Read More

Write a recursive, string -valued  function, reverse, that accepts a string  and returns a new string  consisting of the original string  in reverse.

C++

LANGUAGE: C++ CHALLENGE: Write a recursive, string -valued  function, reverse, that accepts a string  and returns a new string  consisting of the original string  in reverse. For example, calling reverse with the string  goodbye returns the string  eybdoog. Reversing a string  involves: No action if the string  is empty or has only 1 character  (reversing a…

Read More

Declare  an array  named  winarr, consisting of 3 Window objects , where the first element  is an 80×20 window, the second a 10×10 window, and the third a 133×40 window.

C++

LANGUAGE: C++ CHALLENGE: Assume  a class  Window with a constructor  that accepts two integer  arguments : width and height (in that order). Declare  an array  named  winarr, consisting of 3 Window objects , where the first element  is an 80×20 window, the second a 10×10 window, and the third a 133×40 window.

Read More