Monday, September 25, 2017

Looping Structure - Find Output [22 Programs] SEE Qbasic Practice PART I

1.      DECLARE SUB Result()
CLS
CALL Result
END
SUB Result
A=1
FOR I = 1 TO 5
PRINT I*A
A=A+(10^I)
NEXT I
END SUB

2.      DECLARE SUB SHOW ()
CLS
CALL SHOW
END
SUB SHOW
X=30
Y=10
FOR C= 1 TO 2
PRINT X; Y;
X=X\Y
Y=X-Y
NEXT C
END SUB

3.      DECLARE SUB Show ( )
CLS
CALL Show
END
SUB Show
C=3
B=2
FOR I=2 TO 8 STEP 2
PRINT C,
SWAP B, C
B=C+1
NEXT I
END SUB

4.      DECLARE SUB SERIES ( )
CLS
CALL SERIES
END

SUB SERIES ( )
FOR J = 8 TO 2 STEP-2
PRINT D;
SWAP D, B
D = B + 1
NEXT J
END SUB

5.      DECLARE SUB SERI ( )
CLS
CALL SERI
END
SUB SERI ( )
N=1
FOR I=1 TO 10
PRINT N;
N=N+2
NEXT I
END SUB

6.      DECLARE SUB Series()
CALL Series
END
SUB Series
X=1
Y=1
FOR Z=1 TO 4
PRINT X;
Y=Y+1
X=X*10+Y
NEXT Z
END SUB

7.      DECLARE SUB Series( )
CALL Series
END

SUB Series
A=2
B=2
For ctr=1 to 2
PRINT A; B;
A= A+B
B=A+B
Next ctr
END SUB

8.      DECLARE SUB Result ( )
CALL Result
END

SUB Result
For I = 1 to 9 STEP 2
Sum=Sum +I^2
Next I
PRINT Sum
END SUB

9.      DECLARE SUB SERIES()
CLS
CALL SERIES
END

SUB SERIES( )
X=11111
FOR I= 1 TO 5
PRINT X^2
X = (X - 1) / 10
NEXT I
END SUB



10.   DECLARE SUB SER ( )
CALL SER
END

SUB SER
A=1
B=1
FOR I=1 TO 10 STEP 2
PRINT A*B
A=A*10 + 1
B=B+1
NEXT I
END SUB

11.   DECLARE SUB num ( )
CLS
CALL num
END

SUB num
F = 2
S = 1
FOR K = 5 TO 1 STEP -1
A = A + S
PRINT A
S = S + F
NEXT K
END SUB

12.   DECLARE SUB skill( )
CLS
CALL skill
END

SUB skill
LET N=5
LET A=4
FOR  J = 1 TO 5 STEP 1
PRINT N
N=N*10+A
A=A+1
NEXT  J
END SUB

13.   DECLARE SUB RESULT ( )
CLS
CALL RESULT
END

SUB RESULT ( )
Z = 3
FOR A = 1 TO 10
PRINT (A^2)*Z
NEXT A
END SUB

14.   DECLARE SUB SHOW( )
CLS
CALL SHOW
END

SUB SHOW ( )
A = 15
FOR I = 1 TO 4
PRINT A MOD I + 2
SUM = SUM + A \ 10
A = A – 1
NEXT I
PRINT SUM
END SUB

15.   DECLARE SUB SERI()
CLS
CALL SERI
END

SUB SERI()
FOR I= 1 TO 4
FOR J=1 TO I
PRINT (I+J)*10;
NEXT J
PRINT
NEXT I
END SUB

16.   DECLARE SUB CHECK ()
CALL CHECK
END

SUB CHECK
CLS
FOR K = 1 TO 5
FOR I = 5 TO K STEP -1
PRINT I;
NEXT I
PRINT
NEXT K
END SUB

17.   DECLARE SUB FIND(N)
CLS
N=654
CALL FIND(N)
END

SUB FIND(N)
WHILE N < > 0
R= N MOD10
P= P*10 + R
N= N \ 10
WEND
PIRNT P
END SUB

18.   DECLARE SUB SERIES()
CALL SERIES
END

SUB SERIES()
R=2
M=5
WHILE M>=1
PRINT R
R=R*10+2
M=M-1
WEND
END SUB

19.   DECLARE SUB SERU ()
CALL SERU
END
SUB SERU ()
X =2
C =1
WHILE C <=10
S =X^C
PRINT S
C =C+1
WEND
END SUB

20.   DECLARE SUB PER(P)
P=15
CALL SER(12)
END

SUB SERIES (P)
M=3
WHILE M<7
PR=M*P
PRINT PR,
M=M+2
WEND
END SUB

21.   CLS
X=0
Y=0
C=1
WHILE C<=10
CALL Variance ((X), Y)
C=C+1
WEND
END

SUB Variance (A,B)
A=A+10
B=B+10
PRINT A, B
END SUB

22.   DECLARE SUB RESULT()
CALL RESULT
END

SUB RESULT
N=7
C=5
DO UNTIL C=1
PRINT N
N=N*10+7
C=C-1
LOOP
END SUB

No comments:

Post a Comment