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

The loop repetition conditions of for statement is tested at the end of each pas

ID: 3842211 • Letter: T

Question

The loop repetition conditions of for statement is tested at the end of each pass. The body of a while statement must cause the loop repetition condition become false after a finite number of passes to prevent an infinite loop. In counting loops, the counter must be initialized to zero before execution of the loop body begins. The loop condition of while or for statement can be false before loop begins to execute. Loop counter variables are usually of type float. A compound statement is a sequence of statements enclosed in {} braces. The symbol - is the C equality operator. The following decision structure is invalid if x y) {y = x; x = y;} Conditions are said to be mutually exclusive if at most one can condition can be true at a time.

Explanation / Answer

1. False
   The loop repetition condition in a for loop is tested at the begining of each pass.

2. True
   Both while loops and do-while loops are condition-controlled, meaning that they continue to loop until condition is false. Else the loop will become infine loop.

3. False
   The counter may start from any value and repeat upto any value. It works on both increment and decrement function also
Example for(i=2;i<5;i++){
       //body of the loop
       // loop repeats 3 times
   }
   for(i=5;i>2;i--){
       //body of the loop
       // loop repeats 3 times
   }
In both the above codes loop repeats 3 times.

4. True
   The loop repetion condition for a while or for statement can be false before the loop exxecute.
Example: for(i=6;i<5;i++){
       //body of the loop
   }
The above loop doesn't execute as the condition is false.

5. False
   Loop Counter variables are usually of type int (Integer).

6. True
   A compound statement is any number and kind of statements grouped together within curly braces. You can use a compound statement anywhere a statement is required by Java syntax: for(int i = 0; i < 10; i++) { a[i]++;} // Body of this loop is a compound statement.

7. False
   Equality Operator in C is == or !=. = assigns the value to variable

8. True
   The given code snippet is invalid. In order to make it valid the code snippet must be

   if (x<=y)
       printf("%f",x);
   else
       printf("%f",y);
9. True
   If the condition is True, then both the variables x and y becomes equal i.e both x and y becomes x.

10. True
   condition are said to be mutually exclusive if at most one condition can be true at a time.

Please rate it if you get the answer..:)