38 Computer -- Review of Control Statement

3. Write the output of the following programs.a.CLSN=7FOR P= 1 TO 5PRINT NIf N MOD 2 =0 THENN=N/2ELSEN=N*3+1END IFNEXT PENDb)CLSN = 9DOIF N MOD 2 =1 THEN PRINT NN = N - 1LOOP WHILE N >= 3END

3. Write the output of the following programs.


a.
CLS

N=7

FOR P= 1 TO 5

PRINT N

If N MOD 2 =0 THEN

N=N/2

ELSE

N=N*3+1

END IF

NEXT P

END


b)
CLS

N = 9

DO

IF N MOD 2 =1 THEN PRINT N

N = N - 1

LOOP WHILE N >= 3

END

Output:

7

22

11

34

17


Output:

9

7

5

3

Close Open App