Consider the following functions: int func1(int x) { int r, s; r = 2 * x; if (r
ID: 1925155 • Letter: C
Question
Consider the following functions:int func1(int x)
{
int r, s;
r = 2 * x;
if (r > 10)
{
s = x / 2;
}
else
{
s = x / 3;
}
return s - 2;
}
int func2(int a, int b)
{
int r, s;
s = 0;
for(r = a; r < b; r++)
{
s++;
}
return s;
}
What is the output from the following program fragments?
int a, b;
a. a = 10;
cout << func1(a) << endl;
b. a = 5; b = 12;
cout << func2(a, b) << endl;
c. a = 8;
b = func1(a);
cout << a << " " << b << " " << func2(a, b) << endl;
Explanation / Answer
a. a = 10;
cout << func1(a) << endl; 3
b. a = 5; b = 12;
cout << func2(a, b) << endl; 7
c. a = 8;
b = func1(a);
cout << a << " " << b << " " << func2(a, b) << endl; 8 2 0
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.