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

The statements in the body of a while loop may never be executed, whereas the st

ID: 3837938 • Letter: T

Question


The statements in the body of a while loop may never be executed, whereas the statements in the body of a do-while loop will be executed_____. A for statement contains three expressions: initialization, test, and_____ A loop that is inside another loop is called a ____loop The __ statement may be used to stop a loop's current iteration and begin the next one. A special value that marks the end of a list of values is called a(n)____. What 1$ assigned to the variable a given the statement below with the following assumptions: x = 10, y = 7, and z, a, and b are all int variables. a = x > = y; In the statement: while (x++

Explanation / Answer

(17)

   1.   While loop contains an entry condition check. The statements with in the body of the while loop gets executed if only if condition is satisfied.
   2.   Where as do-while loop contains an exit condition check. The statements with in the body of the while loop gets executed at-least once irrespective of condition.
  
   Hence answer is:
      
       Statements in the body of do-while loop gets executed at-least once.
      
______________________________________________________________________________________________________________________________

(18)
   Syntax of for loop is:
  
       for(initialization; test; Increment/Decrement)
      
   Example:
      
       1.   for(i=1; i<=10; i++)
       2.   for(i=1; i<=10; i = i + 5)
       3.   for(i=10; i>=1; i--)
      
   Hence answer is:
      
       Increment/Decrement
      
______________________________________________________________________________________________________________________________

(19)

   1.   A loop present in another loop is called nested loop.
  
   2. Nested loop gets executed once for each iteration of outer loop.
  
   Example:
      
       //Outer Loop
       for(i=1; i<=10; i++)
       {
           //Inner Loop
           for(j=1; j<=5; j++)
           {
              
           }
       }
  
   Hence answer is Nested Loop.
  
______________________________________________________________________________________________________________________________

(20)
  
   1.   The CONTINUE statement may be used to stop a loop's current iteration and begin the next one.
  
   2.   The statements after CONTINUE will not be executed, all of them are skipped.
  
   Hence answer is CONTINUE
      
______________________________________________________________________________________________________________________________

(21)
  
   1.   A special value that marks the end of a list of values is called SENTINEL VALUE
  
   For example:
      
       Statements like "Enter -999 to stop reading values" while reading values from user.
      
   Hence answer is SENTINEL VALUE
  
______________________________________________________________________________________________________________________________

(22)

   In the statement: a = x >= y;
  
   Initially expression x >= y is executed, and returns value 1 (TRUE) as 10 >= 7. As a is an integer variable boolean TRUE representation 1 is stored in variable a.
  
   1.
       a = x >= y;       a = 10 >= 7;   =>   a = 1 (TRUE)
      
       If x = 7, y = 10
      
       a = x >= y;       a = 7 >= 10;   =>   a = 0 (FALSE)
      
      
   Hence correct option is a = 1
  
______________________________________________________________________________________________________________________________

(23)

   In the expression: x++ < 10, Operator < is used first and then ++ operator.
  
   Example that illustrates the situation:
  
       int x=9;

       if(x++ < 10)
           cout << " < " << x ;
       else
           cout << " ++ " << x ;
          
   Output of the this code snippet is "< 10".
  
   Initially x is 9 and condition (9 < 10) is satisfied, so if condition statements gets executed (after x is incremented).
  
   

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