Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

What value is assigned to the integer variable A and E in the statement A = what

ID: 3846702 • Letter: W

Question

What value is assigned to the integer variable A and E in the statement A = what fun(2, 3, 6, E);If E = 11 before the call to the function what_fun() and the function is defined below. Show all values of m and n for partial credit. int what_fun(int a, int b, int c, int& Ref) { int m, n =0; for (m = a;m =, ==!=, &&, a) m=2 && m > t b) m > n/r && !flag ||!(n r) What is the output of this program fragment? Trace the value of n and k for partial for (n = 2;a n;k--) cout

Explanation / Answer

1) E will be 2+3=5, beacause, E 's value will change as it is passed by refernce. and if refernce variables change then original variables also change.

A= 15, because n will be 15. as for loop runs 5 times. and b=3. hence n=3*5=15.

2) a) m==2&&m>r||(n<=r&&0==n/m)

n=1, m=2, r=3

according to precedence rules,

first bracket will evaluate. n<=r which is true. and n/m=0 as 1/2=0 as both are true.hence their && is also true.

after that m>r which is false.then we evaluate m==2 which is true.

the situation becomes : true &&false||true

we first evaluate && which is true&&false = false

then || false||true=true.

henvce ans is true.

b)m>n/r && !flag || ! (n<r&&flag>r)

flag=1,n=1,m=2,r=3

first bracket: n<r=true and flag>r=false true&&false=false and !false=true

then m>n/r which is true. !flag=0 = false

then equatio becomes : true&&flase || true

it is false||true=true

ans : true

3) output:

9

8

7

6

5

10

9

8

7

11

10

9

outer loop runs 3 times and inner 5+4+3 times.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote