You will be randomly assigned one of two programs to write. Please
read the entire problem before jumping into the code! Your program should consist of
several functions in addition to main()
:
main()
, to do the work
of the program.main()
, to appropriately display the results.Use good programming style including comments, useful object/variable names, and descriptive function names. Take a moment before jumping into the code to sketch out the framework of the program: what objects are needed to store what information, which functions youll be needing (including the input and output of the function itself), etc. Only once you have an outline for your program should you begin to code it!
Submit the finished CPP file to the FTP site in its own folder called P4.
You will have 60 minutes to complete the assignment; late submissions will be penalized 5 points for every 5 minutes late.
The following are the two different program requirements:
Problem A
Create a program that uses an array to print a table of the first 20 whole numbers (1..20) in one column, and the corresponding factoral (n!) in the other. As a reminder, the factoral function (n!) is a running multiplication from the starting number to one (example: 5! = 5=120). Hint: youll need to use an array of double-precision floating-point objects in order to store the factoral of all the numbers.
Problem B
Create a program that uses an array to print a table of the powers of 2 from 0 to 19, where one column is n, and the other is 2n. Write your own function to generate the result of 2n, remembering that any number to the 0 power (n0) equals 1.