int x = 1, y = -1; void swapplus1(int n1, int n2){ int temp = n1 + 1; n1 = n2-1; n2 = temp; x= x + n1; } void swapplus2(

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

int x = 1, y = -1; void swapplus1(int n1, int n2){ int temp = n1 + 1; n1 = n2-1; n2 = temp; x= x + n1; } void swapplus2(

Post by answerhappygod »

Int X 1 Y 1 Void Swapplus1 Int N1 Int N2 Int Temp N1 1 N1 N2 1 N2 Temp X X N1 Void Swapplus2 1
Int X 1 Y 1 Void Swapplus1 Int N1 Int N2 Int Temp N1 1 N1 N2 1 N2 Temp X X N1 Void Swapplus2 1 (62.48 KiB) Viewed 22 times
int x = 1, y = -1; void swapplus1(int n1, int n2){ int temp = n1 + 1; n1 = n2-1; n2 = temp; x= x + n1; } void swapplus2(int& n1, int& n2) { int temp = n1 + 1; n1 = n2-1; n2 = temp; } void swapplus3(const int& n1, const int& n2) { int n1val, n2val, temp = n1 + 1; n1val = n2-1; n2val = temp; y -= n2; } void swapplus4(int* p1, int* p2) { int temp = *p1 + 1; *p1 = *p2 + 1; *p2 = temp; x = *p1 + y; } void swapplus5(int* &p1, int* &p2) { int* temp = p1 + 1; } void print(const int& x, const int& y) { cout << "\n x: " << x << "ly: "<< y; } int main() { 2. 3. p1=p2 - 1; p2 = temp; 4. 5. int arr]{ 2, 4, 6, 8, 10, 12, 14}; y = arr[3] / size(arr); } This program outputs 5 lines. What are they? 1. print(x, y); print(x, y); print(x, y); swapplus1(x, y); swapplus2(x, y); swapplus3(x, y); swapplus4(&x, &y); print(x,y); int *px = &x, *py=&y; (*px)--; (*py) -= -7; swapplus5(px, py); print(x, y); return 0;
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply