The following questions are typical of those that might appear on the final exam. Print always means using formOutput.
Write a function reverse(a) that takes an array a and returns a copy of a with elements in reverse order.
Write a program that takes keeps asking the user to enter a number until 0 is entered, and then prints the numbers out in reverse order, with each number on its own line. Give an error alert if the user tries to enter more then 50 numbers. Hint: use an array to store the numbers.
Write a program that prompts for a positive integer n and prints the product of the numbers from 1 up to n. Thus if 5 is entered, it prints 120, because that is 1*2*3*4*5.
Write a function allEqual(a) that takes an array a and returns true if all the values in the array are equal, and false otherwise.
Write a function countLess(v, a) that takes a value v and an array a and returns the number of elements in a that are less than v.
Write a function whereLess(v, a) that takes a value v and an array a and returns the index of the first value in a that is less than v.
Write a function repeatString(s, n) that takes a string s and a number n and returns a string created by concatinating n copies of s. Thus repeatString("abc", 4) would return abcabcabcabc.
The following are harder problems that are valuable exercises,
but are more difficult than final exam questions.
Write a functions xmastree(size) that takes a small positive integer size and prints a Christmas tree with nice proportions. For example, here's a size 3 tree:
* *** *** ***** ***** ******* ******* *** *** ***
Use your imagination in figuring appropriate proportions for the tree. (This was the last assignment in a prior year. It is harder than would be appropriate for the final, but it's a fun exercise.)