Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can somebody explain to me how this works/help me trace the output please? #include using namespace std; int s=1, y=3; void confuse1(int &y, int s)

Can somebody explain to me how this works/help me trace the output please?

#include using namespace std;

int s=1, y=3;

void confuse1(int &y, int s) {

s++;

y++;

}

void confuse2(int b, int *s) {

y = ++(*s);

*s = b;

} void confuse3(int &a, int *s) {

a = *s + 1; (*s)++;

}

int main() {

int s=2;

confuse1( s, y);

confuse2( s, &y);

confuse3( s, &y);

printf("s + y = %d ", s+y);

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Automating Access Databases With Macros

Authors: Fish Davis

1st Edition

1797816349, 978-1797816340

More Books

Students also viewed these Databases questions