Looking for met2502f25-a.sg test answers and solutions? Browse our comprehensive collection of verified answers for met2502f25-a.sg at distance3.sg.digipen.edu.
Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!
Write if the following code fragment doesn't compile or write if the code compiles but has undefined behavior when executed. Otherwise, write the exact text written to the standard output stream.
void boo(int&, int);
void foo(int, int&);
int gx{6};
int main() {
int one{2}, two{5};
boo(one, two);
int x {one + two};
foo(one, two);
x += one - two;
std::cout << x;
}
void boo(int& x, int y) {
int one{y + 12};
x = 2 * y + 5;
y = one + 4;
}
void foo(int x, int& y) {
int gx{::gx};
y = gx * 4;
::gx = x - y;
}
Write if the following code fragment doesn't compile or write if the code compiles but has undefined behavior when executed. Otherwise, write the exact text written to the standard output stream.
void secret(int x, int& y, int& z) {
z = x + y;
int tmp = x;
x = y;
y = 2*tmp;
}
// suppose the following statements comprise function main ...
int one{5}, two{10}, three{15};
secret(one, two, three);
int x {one + two + three};
secret(two, one, three);
x += one + two + three;
std::cout << x;
Write if the following code fragment doesn't compile or write if the code compiles but has undefined behavior when executed. Otherwise, write the exact text written to the standard output stream.
void secret(int& x, int& y) {
x = x - y;
y = y + x;
x = y - x;
}
// assume the following statements comprise function main ...
int one{4}, two{3};
secret(one, two);
int x1{one}, x2{two};
secret(two, two);
int x3{two};
secret(one, one);
int x4{one};
std::cout << x1 << ',' << x2 << ',' << x3 << ',' << x4;
Write if the following code fragment doesn't compile or write if the code compiles but has undefined behavior when executed. Otherwise, write the exact text written to the standard output stream.
void mystery(int const &x, int const& y) {
int temp {x};
x = y;
y = temp;
}
// suppose the following statements comprise function main ...
int a {10}, b {20};
mystery(a, b);
std::cout << a << ',' << b;
Write if the following code fragment doesn't compile or write if the code compiles but has undefined behavior when executed. Otherwise, write the exact text written to the standard output stream.
void mystery(int& x, int *y) {
int temp{x};
x = *y;
*y = temp;
}
// suppose these three statements comprise function main ...
int a{10}, b {20};
mystery(a, &b);
std::cout << a << ',' << b;
Write if the following code fragment doesn't compile or write if the code compiles but has undefined behavior when executed. Otherwise, write the exact text written to the standard output stream.
void secret(int a, int &b) {
int tmp{a};
a = b;
b = tmp;
}
// suppose these two statements comprise function main ...
int xx{}, yy{11};
secret(xx, yy);
std::cout << xx << ',' << yy;
Write if the following code fragment doesn't compile or write if the code compiles but has undefined behavior when executed. Otherwise, write the exact text written to the standard output stream.
int secret(int &aa) {
return ++aa;
}
// suppose these two statements comprise function main ...
int xx{};
std::cout << xx << ',' << secret(xx) << ',' << xx;
Given the following code fragment:
int x{10}, *p{&x};
int const& r{x};
bool flag {*p == r};
which of the following options is correct?
Write if the following code fragment doesn't compile or write if the code compiles but has undefined behavior when executed. Otherwise, write the exact text written to the standard output stream.
int x {10};
int const & y {x};
y = 30;
std::cout << x << ',' << y;
Write if the following code fragment doesn't compile or write if the code compiles but has undefined behavior when executed. Otherwise, write the exact text written to the standard output stream.
int x{10}, xx{100}, &y{x};
y = xx;
++y;
std::cout << x << ',' << xx << ',' << y;