Professional Documents
Culture Documents
Built in Function Review Sheet
Built in Function Review Sheet
Review Sheet
1. Next to each language feature, please write the header file that we must
include to use that feature.
cout and cin ----- IOSTREAM
the string data type ----- STRING
setprecision() -----IOMANIP
pow(), sqrt(), fabs() ----- CMATH
10. Please determine what is printed to console for the following code
snippets:
a. cout << pow(1.0, 2.0) << endl; ----- 1^2 = 1.0
e. double x = 16.0;
cout << sqrt(x) << endl; ----- 4.0
f. cout << pow(pow(2.0, 2.0), sqrt(4.0)) << endl; ----- pow(4, 2) = 4^2 = 16
11. Let us assume a built-in function named compute() exists. You are told
that compute() accepts 3 parameters, an int, a double, and a string in this
order. You are also told that compute() returns a bool. Please write code
that would call this function and catch the return value in the appropriate
data type. You can use any values you like for the arguments to the function
– the goal is to verify your function call syntax.
13. For question 12, what is the return type of the resize() function?
bool
14. The following is the Euclidean distance formula. It can be used to find
the distance between two points on a cartesian plane (i.e., the x-y axis). On
the back of the current page, please write a full program that asks the user
for the x and y values of two points and uses the built-in functions you have
learned to evaluate the distance.
d = √¿¿
double x1, x2, y1, y2;
cout << “Please enter the values for x1, x2, y1, y2: ”;
cin >> x1 >> x2 >> y1 >> y2;