What value is assigned to the integer variable A and E in the statement A = what
ID: 3846709 • 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--) coutExplanation / Answer
/////////////////////////////////////////////////////::Q.1::///////////////////////////////////////////////////////////////////////////
Value of A = 15.
Value of E = 11.
values for m & n
m = {2,3,4,5,6};
n= {0,3,6,9,12};
////////////////////////////////////////////////////::Q.2:://////////////////////////////////////////////////////////////////////////
Q.2 : -->
a) True.
m==2 && m>r || (n<=r && 0==n/m) :-->
m>r is false
m==2 is true
so,
m==2 && m>r is false statement
but
n<=r and 0==n/m both are true,
hence that entire statement is true.
b) True.
m>(n/r) && !flag || !(n<r&&flag>r) :
m>n/r true (n/r=1/3 which is less than 2)
!flag is flase
so first statement before || (OR) is false
!(n<r&&flag>r)
n<r is true but the flag>r is false and !(false) is true.
hence entire statement is true
////////////////////////////////////////////////////::Q.3:://////////////////////////////////////////////////////////////////////////
Q.3:-->
Output :
9
8
7
6
5
10
9
8
7
11
10
9
////////////////////////////////////////////////////::End:://////////////////////////////////////////////////////////////////////////
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.