Question: 1. void func(int& val1, int val2) { int temp = val1; val1 = val2; val2 = temp; } Given the function definition above, what will

1.

void func(int& val1, int val2) { int temp = val1; val1 = val2; val2 = temp; } 

Given the function definition above, what will the following code print out?

 int num1 = 4; int num2 = 17; func(num2, num1); cout << num1 << ", " << num2 << endl; 

2.

Assume we've already declared and initialized a variable called val to hold some positive integer. The following code is supposed to print "true" if val has an integer square root and "false" otherwise. Which line should replace the comment?

 int count = 0; // which line goes here? count++; if (count * count == val) cout << "true" << endl; else cout << "false" << endl; 

while (count * count != val)

while (count * count < val)

while (count * count <= val)

3.

 string str = "ARTISTIC BATTLE TURTLE"; string output = ""; int counter = 1; while (str.at(counter) != 'T') { output += str.at(counter); counter += 3; } cout << output << endl; 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!