The questions of Test_2
with two possible answers - one correct (yes) and one incorrect (no)


Mark the correct/incorrect assertions about functions.

(no)
  Each function receives input parameters only from number types.
(yes) Functions need to be defined before they can be used.




We have the following function declaration:

    int mark(int n, int m);

Mark the correct/incorrect statements. Suppose that the integer variable comma is defined and its current value is 0.

(yes) cout << mark(10, comma);

(no)  cout <<
mark(2);



We have the following function definition:

    int hard(int n)
    { if (n % 3 > 1) return n;
      else           return n + 1;
    }

Does the statement prints out an even number?

(no)  cout << hard(0);
(yes) cout << hard(1);



Mark with "yes'' the statements in which the loop body executes exactly once. Suppose that info is an integer variable and its current value is 0.

(no) while (info > 0) info++;
(yes) while (info <= 0) info++;



Mark with "yes'' the program code excerpt where the body of the loop statement executes 3 times
exactly. The variable i is already defined and has int type.

(yes) i=1; while(i<4) i++;
(no)  i=1; while(i<=4) i++;



Mark with "yes" infinite loops and with "no" finite loops. The value of the integer variable far is obtained from the input stream.

(yes) do far++; while (far != 0 || far == 0); 
(no) do far--; while(far > -3200); 




Mark with "yes" the statements in which the loop body executes exactly once. The integer variable beep has value 1.

(yes) while(beep == 1) beep++;
(no) while(false) beep--;




Mark the syntax correct/incorrect loop statements. Variables t, y, h and k have int type. 

(yes) for(t = -1; t < 4; t++) cout << t; 

(no) for{y = 1; y < 10; y++} cout << h;



Mark with "yes" the equivalent logical expressions (1) and (2). 

(yes) 
(1) country == "USA" and state != "AK" (2) not (country != "USA" or state == "AK") 
(no) (1) country == "USA" and state != "HI" (2) not (country != "USA" and state == "HI")



We have: 
   double a, x; 
   bool flag1, flag2; 
Does C++ run-time system compute the following logical expressions using short circuit evaluation?

(yes) cin.fail()||(a < 0) 
(no) !(x >= 0)