CSCI Exam 2
Read the following program:
#include <iostream>
void CalculateSum(int sum){
sum = 0;
for(int i = 0; i < 5; i++){
sum += i;
}
}
int main(){
a. argument
int sum = 0;
CalculateSum(sum); //(sum)
cout << sum << endl;
}
(sum) is best referred to as a(n) ______ when it is
used input to a function.
a. argument
b. global variable
c. parameter
d. static variable
A function can be re-used multiple times
True
throughout your program.
In C++ it is possible for a function to return
multiple independent values in a single return False
statement
In a function prototype, the names of the
True
parameter variables can be left out.
In the function definition below, csquared is known d.
aslocal
what
kind of variable?
, double pythag(double a, double b){
double csquared = pow(a, 2) + pow(b,2);
return csquared;
}
a. global
b. parameter
c. argument
d. local
In the function definition below, (int value1, int value2, int value3) are
known as what kind of variable?
int somefunction (int value1, int value2, int value3){
result = value1 * (value2 + value3) % value2;
result *= 7;
return result + 3;
value parameters
}
a. value parameters
b. global
c. reference parameters
d. arguments
A variable that is accessible by every function in
a program, including main, is called what?
a. local variable
b. global variable
b. global variable
c. static variable
d. program-wide variable
Many functions may have local variables with
True
the same name.
This statement causes a function to end and d. return
optionally send a value back to the part of the
program that called the function.
a. exit
b. quit
c. end
Read the following program:
#include <iostream>
void CalculateSum(int sum){
sum = 0;
for(int i = 0; i < 5; i++){
sum += i;
}
}
int main(){
a. argument
int sum = 0;
CalculateSum(sum); //(sum)
cout << sum << endl;
}
(sum) is best referred to as a(n) ______ when it is
used input to a function.
a. argument
b. global variable
c. parameter
d. static variable
A function can be re-used multiple times
True
throughout your program.
In C++ it is possible for a function to return
multiple independent values in a single return False
statement
In a function prototype, the names of the
True
parameter variables can be left out.
In the function definition below, csquared is known d.
aslocal
what
kind of variable?
, double pythag(double a, double b){
double csquared = pow(a, 2) + pow(b,2);
return csquared;
}
a. global
b. parameter
c. argument
d. local
In the function definition below, (int value1, int value2, int value3) are
known as what kind of variable?
int somefunction (int value1, int value2, int value3){
result = value1 * (value2 + value3) % value2;
result *= 7;
return result + 3;
value parameters
}
a. value parameters
b. global
c. reference parameters
d. arguments
A variable that is accessible by every function in
a program, including main, is called what?
a. local variable
b. global variable
b. global variable
c. static variable
d. program-wide variable
Many functions may have local variables with
True
the same name.
This statement causes a function to end and d. return
optionally send a value back to the part of the
program that called the function.
a. exit
b. quit
c. end