Write down the output of the following BASIC Programs:
1. 10 READ J, K, L
20 FOR I = J TO K STEP L
30 PRINT I
40 NEXT I
50 DATA 2, 10, 3
60 END
2. 10 CLS
20 FOR I = 1 TO 10
30 PRINT I, “MY NAME”
40 NEXT I
50 END
3. 10 READ A, B, C
20 FOR I = A TO B STEP C
30 PRINT I
40 NEXT I
50 DATA 2, 10, 2
60 END
4. 10 CLS
20 INPUT U, V
30 LET W = U + V
40 LET Y = W * V
50 LET Z = Y/U
60 PRINT U, V
70 PRINT W, Y, Z
80 END
5. 10 CLS
20 LET R = -2
30 FOR T = 2 TO 15
40 LET R = R + 1
50 PRINT R
60 NEXT T
70 END
6. 10 A = 5: B = 13: C = 931
20 C = 5 * A Ù B + B Ù 2/2
30 PRINT C
40 END
7. 10 FOR I = 1 TO 100 STEP 10
20 PRINT I
30 IF I = 10 THEN I = 100
40 NEXT I
50 END
8. 10 CLS
20 N$ = “ABDUS-SAMAD”
30 N1$ = LEFT$ (N$, 1)
40 N2$ = MID$ (N$, 5, 1)
50 N3$ = MID$ (N$, 8, 1)
60 N4$ = RIGHT$ (N$, 1)
70 NN$ = N1$ + N2$ + N3$ + N4$
80 PRINT NN$
90 END
9. 10 X$ = “DATA – SOFT”
20 FOR I = 1 TO 9
30 Y$ = LEFT$ (X$, I)
40 PRINT Y$
50 NEXT I
60 END
10. 10 LET A = 11
20 WHILE A < 99
30 LET A = A + 11
40 PRINT A
50 WEND
60 END
11. 10 LET A = 0
20 LET B = 1
30 LET C = A + B
40 PRINT C
50 LET A = B
60 LET B = C
70 IF C < 21 THEN GOTO 30
80 END
12. 10 CLS
20 FOR I = 1 TO 10
30 FOR J = 1 TO I
40 PRINT I;
50 NEXT J
60 PRINT
70 NEXT I
80 END
13. 10 FOR A = 10 TO 0 STEP –2.5
20 PRINT A
30 LET S = S + A
40 NEXT A
50 ? S
60 END
14. 10 CLS
20 LET K = -1
30 FOR L = 1 TO 20
40 LET K = K + 2
50 PRINT K;
60 NEXT L
70 END
15. 10 ? “This is first line”
20 ? “It is second row”
30 ? “What is it?”
40 ? “Remember where it should be!”
16. 10 CLS
20 FOR I = 1 TO 8
30 PRINT X
40 PRINT I
50 NEXT I
60 END
17. 10 CLS
20 A = A + 1
30 B = A Ù 2
40 C = A Ù 3
50 D = A Ù 4
60 PRINT A, B, C, D
70 IF A = 6 THEN END ELSE GOTO 20
18. 10 LET K = -1
20 FOR I = 1 TO 20
30 LET K = K + I
40 PRINT K
50 NEXT I
19. 10 FOR I = 1 TO 10
20 PRINT I, “PAKISTAN ZINDABAD”
30 NEXT I
40 END
20. 10 FOR X = 0 TO 20 STEP 2
20 SUM = SUM + X
30 PRINT X, SUM
40 NEXT X
21. 10 FOR X = 6 TO 18 STEP 2
20 LET A = X- 4
30 IF A = 10 THEN 60
40 PRINT A, X
50 GOTO 70
60 PRINT “X=”;X
70 NEXT X
80 END
Comments :
Post a Comment
Note: Only a member of this blog may post a comment.