Name: ____________________________________________________ Alpha: _____________________

Describe help received: _________________________________________________________________

  1. {20pts} Assuming the following function prototypes and variable definitions, write each expressions's type and value. Note: each expression should be taken as independent. I.e. if one expression modifies some variable values, those modifications do not carry over to the next expression.
  // Function prototypes - each of these functions does what the name says it does
  int abs(int j); // returns "absolute value" of j.  defined in library cstdlib
  double round(double x); // returns x rounded to nearest integer. defined in library cmath
  string to_string(int val); // returns string representing val. defined in library string
                             // Note: only there in a newer version of C++ than we're using.
  // Variable definitions
  int k = 2;
  double x = 2.75;
  string s = "hello";
k + abs(-2)
x + abs(-2)
round(x) + k
k = round(x)
s + to_string(k + 3)
(5 + 8)/round(x - 1)
k++ < x
++k < x
k++ < x && k > x
  1. {80pts} This program is missing the definition of the function firstfactor. Complete the program by defining the function (a description of what the function is supposed to do is given in the source code's comments). When your program is working correctly, a typical run might look like this:

    Enter an integer larger than 1: 60
    The factorization of 60 is (2)(2)(3)(5)

Turn in a printout of this cover sheet with your answers to the questions, your source code, and a screen capture of your program running the input 21978.
Challange modify the program so that it prints multiple factors with an exponent, rather than repeated, so that the factorization of 40 would be given as (2)^3(5) rather than (2)(2)(2)(5).