Past perfect or present perfect?
(Respondan en MINÚSCULA, sin puntos y sin contraer verbos).
You can have that newspaper. I (finish) with it.
What is the value returned by f(3)?
int f(int x, int &c) {
c++;
if (x <= 1) return x;
else return f(x - 1, c) + f(x - 2, c);
}
int f(int n) {
int c = 0;
int r = f(n, c);
return r + c;
}
What is the output of the following program?
void f(int& x, int& y, int z) {
if (x > y) x = z;
else y = z;
}
int main() {
int a = 1, b = 2, c = 3;
f(a, b, c);
f(a, c, b);
cout << a << ' ' << b << ' ' << c << '\n';
return 0;
}
Consider the namespace and function definitions below. In which of the following cases would a new function declaration overloading of be invalid?f
namespace a {
int f(int x, int y = 3) { return x + y; }
}
namespace b {
int f(int x=1) { return x + 1; }
double f(int x, double y) { return x + y; }
}
int f(int x) {
return x;
}
Consider the following code fragment:
namespace a {
namespace b {
int f(int x, int y=1) { return x + y; }
}
int f(int x) { return x > 1 ? x + 1 : a::b::f(x - 1); }
}
int g(int x) {
return x % 3 == 0 ? a::b::f(x, 3) : a::f(x);
}
What is the value returned by g(x) for when x equals 1, 2, and 3 respectively?
What is the output of the following program?
void f(int& x, int& y) {
if (x > y) {
int t = x;
x = y;
y = t;
}
}
void f(int& x, int y, int& z) {
f(x, y);
f(y, z);
f(x, y);
}
int main() {
int x = 3, y = 1, z = 2;
f(x, y, z);
cout << x << " - " << y << " - " << z << endl;
return 0;
}
What is the output of the following code?
int x = 10;
int& xRef = x;
cout << ++x << " - ";
cout << xRef++ << " - ";
cout << x << " - " << (x==xRef) << endl;
Suppose there is a function f declared as:
bool f(int x, double y);
Which of the following overloadings of f would be invalid?
"Be going to" is used for planned actions.
What happens if you try to access a key in a dictionary that does not exist?