Cis 324 Midterm and Answers

2750 words 11 pages
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
…show more content…

int main()
{
int score = 0; cout << "Enter your score: "; cin >> score; if (score < 40) { cout << "F" << endl; } else if (score >= 40 || score < 50) { cout << "D" << endl; } else if (score >= 50 || score < 60) { cout << "C" << endl; } else if (score >= 60 || score < 70) { cout << "B" << endl; } else if (score >= 70 || score < 80) { cout << "B+" << endl; } else { cout << "A" << endl; } return 0;
}Answer | | | | | Selected Answer: | D | Correct Answer: | D | | | | |
Question 16
2 out of 2 points | | | What is the output of the following code snippet? int main()
{
int num = 100; if (num > 100);
{
num = num - 10;
}
cout << num << endl; return 0;
}Answer | | | | | Selected Answer: | 90 | Correct Answer: | 90 | | | | |
Question 17
0 out of 2 points | | | What is the output of the following code snippet?
#include <iostream>
#include <string> using namespace std; int main()
{
string str1 = "her"; string str2 = "cart"; if (str1 < str2)
{
cout << str2;
}
else
{
cout << str1;
}
return 0;
}Answer | | | | |

Related