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

The loop repetition condition of a for statement is tested at the end of each pa

ID: 3842124 • Letter: T

Question

The loop repetition condition of a for statement is tested at the end of each pass. The body of a while statement must cause the loop repetition condition to 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 repetition condition of a while or for statement can be false before the 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 leftarrow y printf ("%f", x); else printf ("%f", y); The following program segment gives x and y the same value if the condition is true: if (x > y) {y = x; x = y;} Conditions are said to be mutually exclusive if at most one condition can be true at a time.

Explanation / Answer

1) False, for loop is a pretest type of repetition structure and loop condition appears at the beginning.

2) True, in while the body needs to have go some logic to make the repetition condition false in order to stop the loop to process further.

3) False, the counter should be initialized but not necessarily to 0.But yes it is ideal to start with 0

4) True, the loop repetition condition of while or for can be false before loop begins to execute but in that scenario the control will not go inside loop and there will be no iterations at all.

5) False, loop counter variables are usually of type int.

6) True, compound statement is collection of statement enclosed within {} braces, also sometime called body of function/if statement/loops etc.

7) False, equality operator is = = not =.

8) No the decision is not invalid as this compares x with y and if x is less than or equal to y then it will print c else will print y.

9) True, it gives the same value as we are first assigning the value of x to y and now y has the new value which is x and x gets the this value.

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