Page 1 of 1

static int x = 1; int y = x * 2; void t1() { y++; } void t2() { } void t3() { } cout << "x: " << x << " | y: " << y << e

Posted: Tue Jul 12, 2022 8:16 am
by answerhappygod
Static Int X 1 Int Y X 2 Void T1 Y Void T2 Void T3 Cout X X Y Y E 1
Static Int X 1 Int Y X 2 Void T1 Y Void T2 Void T3 Cout X X Y Y E 1 (56.78 KiB) Viewed 21 times
static int x = 1; int y = x * 2; void t1() { y++; } void t2() { } void t3() { } cout << "x: " << x << " | y: " << y << endl; y += 1; x = -1; } void t4() { 2. int* x = &y; cout << "x: " << x <<" | y: "<<y << endl; } int main() { 3. 4. int y = x; static int x = 2; cout << "x: " << x + 1 << " | y: " << y + x << endl; x += y; 5. int y = x + 1; int& z = y; z += -1; cout << "x: " <<x+z<< " | y: "<<y << endl; This program outputs 5 lines. What are they? 1. vector<int> vec1 { 1, 3, 5, 7, 9 }; vector<int> vec2{ 2, 4, 6, 8, 10 }; vec1.swap(vec2); int* ptr = &vec1[1]; y = *(ptr + 2); t1(); t2(); t3(); t3(); t4(); return 0;