Name_______________________
Login___________________SID________
CS 010: Introduction to
Computer Science I
Quiz 5: 10 minutes
- Parameters
and return types can only be fundamental types.
- TRUE
- FALSE
- A
return statement always terminates the program.
- TRUE
- FALSE
- Assuming
that x is a double, the
following statement is a valid statement.
cout << sqrt(pow(x, 4));
- TRUE
- FALSE
For the next 3 questions, assume there
is a the following function header (prototype):
void func(int,
double)
- Given
the function func above, the
following statement is valid.
cout << func(4, 13.9);
- TRUE
- FALSE
- Given
the function func above, the
following statement is valid.
func(rand(), 2.2);
- TRUE
- FALSE
- Given
the function func above, the
following statement is valid.
func(7.7, 11);
- TRUE
- FALSE
- The
expression rand() % 50 + 10 would result in a range of
- 0-49
- 1-50
- 10-50
- 10-59
- None
of the above
Use the code below for the next 3
questions.
double func1(double x)
{
if
(x <= 20)
{
return
x;
}
else
{
return
100;
}
}
double func2(double a)
{
double
b = pow(a, a);
cout
<< b << endl; //
OUTPUT 1
double
c = func1(b);
cout
<< c << endl; //
OUTPUT 2
return
b + c;
}
int main()
{
cout
<< func2(3) + 5 << endl; //
OUTPUT 3
return
0;
}
- What
will OUTPUT 1 print?
- 3
- 9
- 27
- 32
- None
of the above
- What
will OUTPUT 2 print?
- 3
- 20
- 27
- 100
- None
of the above
- What
will OUTPUT 3 print?
- 8
- 41
- 127
- 132
- None
of the above