05 Jun CS 225 – What will be displayed on the console
Question
What will be displayed on the console given the following code fragment?
int main() {
int num1 = 3;
int num2 = 4;
myFunction (num1, num2);
system(“pause”);
return 0;
}
void myFunction (int num1Par, int num2Par) {
cout << num1Par << num2Par;
}
A) 33
B) 34
C) 35
D) 36
Question 2
What will be displayed on the console given the following code fragment?
int main() {
int num1 = 3;
int num2 = 4;
myFunction (num1, num2);
return 0;
}
void myFunction (int num1Par, int num2Par) {
num1Par++;
num2Par++;
cout << num1Par << num2Par;
}
A) 42
B) 43
C) 44
D) 45
Question 3
What will be displayed on the console given the following code fragment?
int main() {
int num1 = 3;
int num2 = 4;
myFunction (num1, num2);
return 0;
}
void myFunction (int num1Par, int num2Par) {
num1Par++;
num2Par++;
++num1Par;
++num2Par;
cout << num1Par << num2Par;
}
A) 65
B) 56
C) 23
D) 43
Question 4
What will be displayed on the console given the following code fragment?
int main() {
int num1 = 3;
int num2 = 4;
myFunction (num1, num2);
system(“pause”);
return 0;
}
void myFunction (int num1Par, int num2Par) {
cout << pow(num2Par,num1Par);
}
A) 33
B) 46
C) 64
D) 65
Question 5
What will be displayed on the console given the following code fragment?
int main() {
int num1 = 4;
int num2 = 3;
myFunction (num1, num2);
system(“pause”);
return 0;
}
void myFunction (int num1Par, int num2Par) {
cout << pow(num2Par,num1Par);
}
A) 81
B) 80
C) 79
D) 77
Question 6
What will be displayed on the console given the following code fragment?
int main() {
int num1 = 2;
int num2 = 2;
myFunction (num1, num2);
return 0;
}
void myFunction (int num1Par, int num2Par) {
cout << pow(num2Par,pow(num1Par,num2Par));
}
A) 14
B) 15
C) 16
D) 13
Question 7
What will be displayed on the console given the following code fragment?
int main() {
int num1 = 18;
int num2 = 2;
cout << modIt(num1, num2);
return 0;
}
int modIt(int num1Par, int num2Par) {
return num1Par % num2Par;
}
A) 2
B) -1
C) 1
D) 0
Question 8
What will be displayed on the console given the following code fragment?
int main() {
int num1 = 1234561;
int num2 = 2;
cout << modIt(num1, num2);
return 0;
}
int modIt(int num1Par, int num2Par) {
return num1Par % num2Par;
}
A) 4
B) 3
C) 2
D) 1
Question 9
What will be displayed on the console given the following code fragment?
int main() {
int aSide = 3;
int bSide = 4;
myFunction (aSide, bSide);
return 0;
}
void myFunction (int num1Par, int num2Par) {
cout << sqrt(pow(num1Par,2.0) + pow(num2Par, 2.0));
}
A) 5555
B) 555
C) 55
D) 5
Question 10
What will be displayed on the console given the following code fragment?
int main() {
int num1 = 3;
int num2 = 4;
myFunction (num1, num2);
return 0;
}
void myFunction (int num1Par, int num2Par) {
cout << pow(num2Par,num2Par);
}
A) 245
B) 256
C) 222
D) 652
Question 11
What will be displayed on the console given the following code fragment?
int main() {
int num1 = 3;
int num2 = 4;
myFunction (num1, num2);
return 0;
}
void myFunction (int num1Par, int num2Par) {
cout << sqrt(num2Par);
}
A) 5
B) 4
C) 3
D) 2
Question 12
What will be displayed on the console given the following code fragment?
int main() {
int num1 = 3;
int num2 = 4;
myFunction (num1, num2);
cout << (num1 * num2);
return 0;
}
void myFunction (int num1Par, int num2Par) {
cout << num1Par << num2Par;
}
A) 1234
B) 3412
C) 1423
D) 2345
Question 13
What will be displayed on the console given the following code fragment?
int main() {
int num1 = 3;
int num2 = 4;
num1 = myFunction (num1, num2);
cout << num1;
return 0;
}
int myFunction (int num1Par, int num2Par) {
cout << num1Par << num2Par;
return (num1Par * num2Par);
}
A) 1234
B) 3412
C) 4312
D) 3222
Question 14
What will be displayed on the console given the following code fragment?
int main() {
int num1 = 3;
double num2 = 4.0;
num1 = gradeIt(num2);
cout << num1;
return 0;
}
int gradeIt (double scorePar) {
if (scorePar >= 60.0)
return 1;
else
return -1;
}
A) 2
B) 1
C) 0
D) -1
Question 15
What will be displayed on the console given the following code fragment?
int main() {
double num2 = 4.0;
string message = “”;
cout << gradeIt(num2);
return 0;
}
string gradeIt (double scorePar) {
if (scorePar < 60.0)
return “Passed”;
else
return “Failed”;
}
A) Passed
B) Failed
C) PassedFailed
D) none of the above
Question 16
What will be displayed on the console given the following code fragment?
int main() {
double num2 = 4.0;
string message = “”;
cout << gradeIt(pow(20, num2));
return 0;
}
string gradeIt(double scorePar) {
if (scorePar > 60.0)
return “Passed”;
else
return “Failed”;
}
A) Passed
B) Failed
C) Pass
D) Fail
Question 17
What will be assigned to variable messagegiven the following code fragment?
int main() {
int num1 = 3;
int num2 = 5;
double num3 = 6.0;
string message = “”;
message = gradeIt(num2) + gradeIt(num1, num2);
return 0;
}
string gradeIt (double scorePar) {
if (scorePar < 60.0)
return “Passed”;
else
return “Failed”;
}
string gradeIt (int num1Par, int num2Par) {
if (num1Par > 3 && num2Par > 3)
return “YES”;
else
return “NO”;
}
A) PassedNO
B) PassedYES
C) Passed
D) YES
Question 18
What will be assigned to variable statementgiven the following code fragment?
int main() {
int num1 = 3;
int num2 = 5;
double num3 = 6.7;
string statement = “CS”;
statement = gradeIt(num2, num3);
return 0;
}
string gradeIt (double scorePar) {
if (scorePar < 60.0)
return “Passed”;
else
return “Failed”;
}
string gradeIt (int num1Par, int num2Par) {
if (num1Par > 3 && num2Par > 3)
return “YES”;
else
return “NO”;
}
string gradeIt (int num1Par, double num2Par) {
return to_string(num1Par * (int)num2Par);
}
A) 20
B) 30
C) 40
D) 50
Question 19
What will be assigned to variable outputgiven the following code fragment?
int main() {
double num1 = 3;
double num2 = 5;
int num3 = 9;
string output = “CS”;
output = output + modIt(num3) + modIt(num1, num2);
return 0;
}
string modIt(int num3Par) {
return to_string(num3Par) + “ABC”;
}
string modIt (double num1Par, double num2Par) {
return “CS225”;
}
A) CS9AB
B) CS9ABCCS
C) CS9ABCCS22
D) CS9ABCCS225
Question 20
What will be assigned to variable outputgiven the following code fragment?
int main() {
double num1 = 3;
double num2 = 5;
int num3 = 9;
string output = “CS”;
output = output + concatIt(num3) + concatIt(num1+1.0, num2+2.0);
}
string concatIt(int num3Par) {
return to_string(num3Par) + “ABC”;
}
string concatIt(double num1Par, double num2Par) {
return “CS225”;
}
A) CS9ABCCS
B) CS9ABCCS225
C) ABCCS225
D) CS9S225
Question 21
What will be assigned to variable resultgiven the following code fragment?
int main() {
double num1 = 3;
double num2 = 5;
int result;
result = modIt(num2, num1);
return 0;
}
int modIt (double num1Par, double num2Par) {
return (int)pow(num1Par, num2Par);
}
A) 125
B) 124
C) 123
D) 122
Question 22
What will be the final value of variable num2when the program is executed given the following code fragment?
int main() {
double num1 = 3;
double num2 = 5;
int result;
result = modIt(num2, num1);
}
int modIt(double &num1Par, double &num2Par) {
num1Par++;
num2Par++;
return (int)pow(num1Par, num2Par);
}
A) 9
B) 8
C) 6
D) 7
Question 23
What will be the final value of variable num1when the program is executed given the following code fragment?
int main() {
double num1 = 3;
double num2 = 5;
int result;
result = modIt(num2, num1);
}
int modIt(double &num1Par, double &num2Par) {
num1Par++;
num2Par++;
return (int)pow(num1Par, num2Par);
}
A) 1
B) 2
C) 3
D) 4
Question 24
What ultimately will be assigned to variable answergiven the following code fragment?
int main() {
int num3 = 9;
string answer = “CS”;
answer = modIt(num3);
answer = answer + to_string(num3);
return 0;
}
string modIt(int &num3Par) {
num3Par++;
return to_string(num3Par);
}
A) 10
B) 1010
C) 101010
D) 0101
Question 25
The output of the statement: cout << pow(3.0, 2.0) + 5 << endl; is ____.
A) 11.0
B) 12.0
C) 13.0
D) 14.0
Question 26
The output of the statement:
cout << pow(2.0, pow(3.0, 1.0)) << endl;
is ____.
A) 6.0
B) 7.0
C) 8.0
D) 9.0
Question 27
The heading of the function is also called the ____.
A) title
B) function signature
C) function head
D) function header
Question 28
A variable listed in a header is known as a(n) ____ parameter.
A) actual
B) local
C) formal
D) function
Question 29
Given the following function prototype: int test(float, char);, which of the following statements is valid?
A) cout << test(12, &);
B) cout << test(“12.0”, ‘&’);
C) int u = test(5.0, ‘*’);
D) cout << test(’12’, ‘&’);
Question 30
A function prototype is ____.
A) a definition, but not a declaration
B) a declaration and a definition
C) a declaration, but not a definition
D) a comment line
Question 31
Suppose that you have the following declaration.
enum cars {FORD, GM, TOYOTA, HONDA};
cars domesticCars = FORD;
The statement:
domesticCars = static_cast<cars>(domesticCars + 1);
sets the value of domesticCars to ____.
A) FORD
B) GM
C) TOYOTA
D) HONDA
Question 32
Consider the declaration:
enum sports {BASKETBALL, FOOTBALL, HOCKEY, BASEBALL, SOCCER};
which of the following statements is true?
A) SOCCER– = BASEBALL
B) BASEBALL++ = SOCCER
C) HOCKEY + FOOTBALL < SOCCER
D) FOOTBALL <= SOCCER
Question 33
What is the output of the following code?
enum courses {ALGEBRA, BASIC, PASCAL, PHILOSOPHY, ANALYSIS};
courses registered;
registered = ALGEBRA;
cout << registered << endl;
A) ALGEBRA
B) 0
C) 1
D) “ALGEBRA”
Question 34
Which of the following statements creates an anonymous type?
A) enum grades {A, B, C, D, F};
B) enum grades {};
C) enum {};
D) enum {A, B, C, D, F} grades;
Question 35
Before using the data type string, the program must include the header file ____.
A) enum
B) iostream
C) string
D) std
Question 36
Suppose str = “ABCDEFGHI”. The output of the statement
cout << str.length() << endl;
is ____.
A) 7
B) 8
C) 9
D) 10
Question 37
The length of the string “Hello There. ” is ____.
A) 11
B) 12
C) 13
D) 14
Question 38
Consider the following statements:
string str = “ABCDEFD”;
string::size_type position;
After the statement position = str.find(‘D’); executes, the value of position is ____.
A) 3
B) 4
C) 6
D) 7
Question 39
Considering the statement string str = “Gone with the wind”;, the output of the statement cout << str.find(“the”) << endl; is ____.
A) 9
B) 10
C) 11
D) 12
Question 40
The ____ function is used to interchange the contents of two string variables.
A) iterator
B) traverse
C) swap
D) change
Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.
About Writedemy
We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.
How It Works
To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Are there Discounts?
All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.
