Cis 324 Midterm and Answers

Only available on StudyMode
  • Topic: C++, Subroutine, Java
  • Pages : 19 (2743 words )
  • Download(s) : 79
  • Published : May 12, 2013
Open Document
Text Preview
User| |
Course| C++ Programming I |
Test| Week 5 Midterm Exam |
Started| 11/12/12 5:06 PM |
Submitted| 11/13/12 10:28 PM |
Status| Completed |
Score| 64 out of 100 points   |
Time Elapsed| 2 hours, 0 minute out of 2 hours. |
Instructions| The midterm exam consists of multiple choice questions. You will have 2 hours to complete it. Good Luck!|

Question 1
0 out of 2 points
| |
| Study the following code snippet:
int greater_num(int num1, int num2)
{
if (num1 < 0 || num2 < 0)
{
cout << "Only POSITIVE Numbers!!!";
return 0;
}
else
{
if (num1 <= num2)
{
return num1;
}
else
{
return num2;
}
}
}
Which of the following describes a constraint on the use of this function?Answer | | | | | Selected Answer:|    All of the above listed items.| Correct Answer:|    The use of cout does not allow this function to be used for a graphics program.|

| | | |
Question 2
2 out of 2 points
| |
| What is helpful when dealing with a complex set of instructions for developing the code?Answer | | | | | Selected Answer:|    Performing a manual walkthrough on a piece of paper before the actual code is written.| Correct Answer:|    Performing a manual walkthrough on a piece of paper before the actual code is written.|

| | | |
Question 3
0 out of 2 points
| |
| Which of the following is true about functions?Answer | | | | | Selected Answer:|    Functions can have multiple parameters and can return multiple return values.| Correct Answer:|    Function can have multiple parameters and can return one return value.|

| | | |
Question 4
0 out of 2 points
| |
| Which of the following must be provided when defining a function?Answer | | | | | Selected Answer:|    A name for the function, a name for each parameter, and a name for the return value| Correct Answer:|    A name for the function, a name and type for each parameter, and a type for the return value|

| | | |
Question 5
2 out of 2 points
| |
| Study the following code snippet:
for (cnt = 0; cnt < 10; cnt++)
{
cout << "I'm too good!!!" << endl;
}
Which of the following debugging commands may be used on the above code snippet for checking if the loop runs 10 times?Answer | | | | | Selected Answer:|    All of the above listed items| Correct Answer:|    All of the above listed items|

| | | |
Question 6
0 out of 2 points
| |
| What is the error in the following function definition?
int doubler(int old_value)
{
double new_value = old_value * 2;
}Answer | | | |
| Selected Answer:|    The function returns a value of type double.| Correct Answer:|    The function does not return a value.|
| | | |
Question 7
2 out of 2 points
| |
| Which of the following is the correct first line of a function definition named calc_average that accepts three int parameters and returns a double?Answer | | | | | Selected Answer:|    double calc_average(int a, int b, int c)| Correct Answer:|    double calc_average(int a, int b, int c)|

| | | |
Question 8
2 out of 2 points
| |
| Which of the following is the best choice for a return type from a function that prompts users to enter their password?Answer | | | | | Selected Answer:|    string|
Correct Answer:|    string|
| | | |
Question 9
2 out of 2 points
| |
| Consider a function named calc, which accepts two numbers as integers and returns their sum as an integer. Which of the following is the correct statement to call the function calc?Answer | | | | | Selected Answer:|    int sum = calc(2, 3);|

Correct Answer:|    int sum = calc(2, 3);|
| | | |
Question 10
0 out of 2 points
| |
| What is created for each input parameter when a function is called?Answer | | | | | Selected Answer:|    None of the above|
Correct Answer:|   ...
tracking img