WAP to print the series : 9,28,14,7,21....10th term

Qbasic program to print the series : 9,28,14,7,21....10th term



 CLS
 A = 9
 FOR I = 1 TO 10
 PRINT A;
 IF A MOD 2 = 0 THEN
 A = A  2
 ELSE
 A = A * 3 + 1
 END IF
 NEXT I
 END

USING SUB


DECLARE SUB SERIES()
 CLS
 CALL SERIES
 END
 
 SUB SERIES
 A = 9
 FOR I = 1 TO 10
 PRINT A;
 IF A MOD 2 = 0 THEN
 A = A  2
 ELSE
 A = A * 3 + 1
 END IF
 NEXT I
 END SUB

Post a Comment

0 Comments