Name: ____________________________________________________ Alpha: _____________________
Describe help received: _________________________________________________________________
// 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 // Variable definitions int k = 2; double x = 2.75; string s = "hello";
expression | type | value |
k + abs(-2) | ||
x + abs(-2) | ||
round(x) + k | ||
k = round(x) | ||
s + to_string(k + 3) | ||
to_string(round(x)) | ||
(5 + 8)/round(x - 1) | ||
k++ < x | ||
++k < x | ||
k++ < x && k > x |
istream
objects, as
in cin.get()
, or fin.get()
when fin
is an ifstream
, looks like
this (this is a bit of a funny function because of the
"cin." in front of the name):
int get();Given this, and what we know about cin.get() and fin.get() work from the previous class, what gets printed out for
cout << cin.get() << endl;as opposed to
char c = cin.get(); cout << c << endl;when the user inputs
Q
? Explain
why each gives the answer it does.
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)