Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started