Public feed #723289

Dark3Lite

public text v1 · immutable
Raw Edit
·published 2007-10-02 17:57 UTC
rendered paste body
In the following Algorithm segments, indicate whether or not the loop will terminate. If it will not, why not? Assume it is all integer variables.

counter <-- 0
total <-- α

DOWHILE counter >= α
       total <-- total + 2

ENDDO

b) total <-- 0
   index <-- 1
   REPEAT
       total <-- total +1
       index <-- index + 1

   UNTIL index = 10

c) counter  <--- 0
   total    <--- 0
 DOWHILE counter < = 10
total <-- total + 2
counter <-- counter + 1
ENDDO 

2. Express the following as a nested IF structure using only simple conditions.

IF a < b AND C != D AND (B > D OR B = D) THEN 

S1        ---Where S1 is a staement.

3. Express the conditions necessary for the execution of the statements s1, s2, s3, s4 in the following as separate compound conditions.

IF (a > b) THEN
   IF (b <= c) THEN
   IF (c!=d) THEN
             s1

   ELSE
        s2
  ENDIF

  ELSE
   s3
ENDIF

ELSE
    s4
ENDIF