int x; //global variable void p(int <parameter-passing-method> y) { x = x + 1; y = y + 2; } void main() { x = 1; p(x); cout << x; }Say what is the value printed by the program when the parameter-passing-method is:
bool non-strict-and(bool <parameter-passing-method> b1, bool <parameter-passing-method> b2)A call of the form
non-strict-and(e1,e2)where e1 and e2 are two generic boolean expressions, should give the same result as the C++ expression
e1 && e2namely: if the value of e1 is false, then the result should be false; otherwise the result should be the same as the value of e2.
The characteristic of such a non-strict operator is that if e1 is false then e2 is not evaluated. Hence even if e2 contains a dynamic error (like a division by 0), the evaluation of e1 && e2 does not give an error (if e1 is false).
void p(int value-result x){ c }where c is a generic sequence of commands, please define the body of an equivalent procedure in C++ using call by reference:
void p(int &x){ ... }You can use, of course, c to refer to the same sequence of command used in the first declaration.
int &x = y;Consider the following two fragments of code in C++:
int &x = y; // create an alias x to y x = x + 1; cout << y;and
int *x; // create a variable x of type pointer x = &y; // assign to x the location address of y *x = *x + 1; cout << y;Are these two fragments equivalent, in the sense that they print the same value (independently from the initial value of y)? Please explain, preferably by using drawings.
void p(int &x){ c }we would like to define an equivalenty procedure
void p(...){...}using only call by value. For each of the following cases, say whether this is possible and, in the positive case, show how p should be defined.