#WAP TO GENERATE THE FOLLOWING SERIES.
#1, 2, 3, 4,…..UPTO 12TH TERM.
DECLARE SUB SERIES()
CLS
CALL SERIES
END
SUB SERIES
FOR I=1 TO 12
PRINT I;
NEXT I
END SUB
#1, 4, 9, 16, ……UPTO 10TH TERM.
DECLARE SUB SERIES()
CLS
CALL SERIES
END
SUB SERIES
FOR I=1 TO 10
PRINT I^2;
NEXT I
END SUB
#1, 8, 27, 64, …UPTO 10TH TERM
DECLARE SUB SERIES()
CLS
CALL SERIES
END
SUB SERIES
FOR I=1 TO 10
PRINT I^3;
NEXT I
END SUB
#2, 5, 10, 17,…UPTO 10TH TERM.
DECLARE SUB SERIES()
CLS
CALL SERIES
END
SUB SERIES
FOR I =1 TO 10
PRINT I^2+1;
NEXT I
END SUB
#2,4,6, 8,10….UPTO 10TH TERM
DECLARE SUB SERIES()
CLS
CALL SERIES
END
SUB SERIES
FOR I =2 TO 20 STEP 2
PRINT I ;
NEXT I
END SUB
#-10,-8,-6,-4…….UPTO 20TH TERMS
DECLARE SUB SERIES()
CLS
CALL SERIES
END
SUB SERIES
A=-10
FOR I =1 TO 20
PRINT A;
A = A + 2
NEXT I
END SUB
# 9,7,5,…….1
DECLARE SUB SERIES()
CLS
CALL SERIES
END
SUB SERIES
FOR I = 9 TO 1 STEP -2
PRINT I ;
NEXT I
END SUB
# 18,15,12,9,………….1
DECLARE SUB SERIES ()
CLS
CALL SERIES
END
SUB SERIES
FOR I = 18 TO 1 STEP -3
PRINT I ;
NEXT I
END SUB
#5, 10, 15, 20, ….,50
DECLARE SUB SERIES()
CLS
CALL SERIES
END
SUB SERIES
FOR I=5 TO 50 STEP 5
PRINT I;
NEXT I
END SUB
#WAP TO FIND THE SUM OF FIRST TEN NATURAL NUMBER USING SUB PROCEDURE.
DECLARE SUB SERIES()
CLS
CALL SERIES
END
SUB SERIES
FOR I=1 TO 10
PRINT I
S=S+I
NEXT I
PRINT “SUM IS=”;S
END SUB
#WAP TO DISPLAY THE FOLLOWING SERIES:
DECLARE SUB SERIES()
CLS
CALL SERIES
END
SUB SERIES
A=1
FOR I=1 TO 10
PRINT A;
A=A+4
NEXT I
END SUB
#WAP TO DISPLAY THE FOLLOWING SERIES: 2,8,18,32,…UPTO 10TH TERMS.
DECLARE SUB SERIES()
CLS
CALL SERIES
END
SUB SERIES
FOR I=1 TO 10
PRINT (A^2)*2;
NEXT I
END SUB
#WAP TO PRINT THE GIVEN SERIES: 5, 55, 555, 5555, 55555.
DECLARE SUB SERIES()
CLS
CALL SERIES
END
SUB SERIES
A=5
FOR I=1 TO 5
PRINT A;
A=A*10+5
NEXT I
END SUB
#WAP TO PRINT THE FOLLOWING SERIES:3, 12, 27, 48, 75
DECLARE SUB SERIES()
CLS
CALL SERIES
END
SUB SERIES
FOR I=1 TO 10
PRINT (I^2)*3;
NEXT I
END SUB
#WAP TO PRINT THE HAIL STONE SERIES:7, 22, 11, 34, 17, ….UPTO 10TH TERM.
DECLARE SUB SERIES()
CLS
CALL SERIES
END
SUB SERIES
N=7
FOR I=1 TO 10
PRINT N;
IF N MOD 2=0 THEN
N=N/2
ELSE
N=N*3+1
END IF
NEXT I
END SUB
#WAP TO FIND THE SQUARE ROOT OF GIVEN NUMBER.
DECLARE SUB SQUARE(N)
CLS
INPUT “ENTER A NUMBER”;N
CALL SQUARE(N)
END
SUB SQUARE(N)
SQ=N^(1/2)
PRINT “SQUARE ROOT OF GIVEN NUMBER “;SQ
END SUB
#WRITE A PROGRAM TO GENERATE THE FOLLOWING FIBONACCI SERIES:1,1,2,3,5,8,13,…UPTO 12THTERM.
DECLARE SUB FIBO()
CLS
CALL FIBO
END
SUB FIBO
A=1
B=1
PRINT A; B;
FOR I=1 TO 10
C=A+B
PRINT C;
A=B
B=C
NEXT I
END SUB
#WRITE A PROGRAM TO GENERATE THE FOLLOWING PATTERNS:
1.
ANDROID
ANDROI
ANDRO
ANDR
AND
AN
A
ANS:
DECLARE SUB PATTERN()
CLS
CALL PATTERN
END
SUB PATTERN
A$= “ANDROID”
FOR I=LEN(A$) TO 1 STEP -1
PRINT LEFT$(A$,I)
NEXT I
END SUB
2.
A
AN
AND
ANDR
ANDR
ANDRO
ANDROI
ANDROID
ANS:
DECLARE SUB PATTERN()
CLS
CALL PATTERN
END
SUB PATTERN
A$= “ANDROID”
FOR I=1 TO LEN(A$)
PRINT LEFT$(A$,I)
NEXT I
END SUB
3.
D
ID
OID
ROID
DROID
NDROID
ANDROID
ANS:
DECLARE SUB PATTERN()
CLS
CALL PATTERN
END
SUB PATTERN
A$= “ANDROID”
FOR I=1 TO LEN(A$)
PRINT RIOGHT$(A$,I)
NEXT I
END SUB
4.
ANDROID
NDROID
DROID
ROID
OID
ID
D
ANS:
DECLARE SUB PATTERN()
CLS
CALL PATTERN
END
SUB PATTERN
A$= “ANDROID”
FOR I=LEN(A$) TO 1 STEP -1
PRINT RIGHT$(A$,I)
NEXT I
END SUB
5.
A
N
D
R
O
I
D
ANS:
DECLARE SUB PATTERN()
CLS
CALL PATTERN
END
SUB PATTERN
A$= “ANDROID”
FOR I=1 TO LEN(A$)
PRINT MID$(A$,I,1)
NEXT I
END SUB
6.
D
I
O
R
D
N
A
ANS:
DECLARE SUB PATTERN()
CLS
CALL PATTERN
END
SUB PATTERN
A$= “ANDROID”
FOR I=LEN(A$) TO 1 STEP -1
PRINT MID$(A$,I,1)
NEXT I
END SUB
7.
A
N
D
R
O
I
D
ANS:
DECLARE SUB PATTERN()
CLS
CALL PATTERN
END
SUB PATTERN
A$= “ANDROID”
T=5
FOR I=1 TO LEN(A$)
PRINT TAB(T); MID$(A$,I,1)
T=T+1
NEXT I
END SUB
8.
D
I
O
R
D
N
A
ANS:
DECLARE SUB PATTERN()
CLS
CALL PATTERN
END
SUB PATTERN
A$= “ANDROID”
T=5
FOR I=LEN(A$) TO 1 STEP -1
PRINT TAB(T); MID$(A$,I,1)
T=T+1
NEXT I
END SUB
9.
A
N
D
R
O
I
D
ANS:
DECLARE SUB PATTERN()
CLS
CALL PATTERN
END
SUB PATTERN
A$= “ANDROID”
T=30
FOR I=1 TO LEN(A$)
PRINT TAB(T); MID$(A$,I,1)
T=T-1
NEXT I
END SUB
10.
D
I
O
R
D
N
A
ANS:
DECLARE SUB PATTERN()
CLS
CALL PATTERN
END
SUB PATTERN
A$= “ANDROID”
T=30
FOR I=LEN(A$) TO 1 STEP -1
PRINT TAB(T); MID$(A$, I, 1)
T=T-1
NEXT I
END SUB