1) Program to find greatest among 3 numbers using SUB
DECLARE SUB GREAT(A,B,C)
CLS
INPUT"ENTER FIRST NUMBER";A
INPUT"ENTER SECOND NUMBER";B
INPUT"ENTER THIRD NUMBER";C
CALL GREAT(A,B,C)
SUB
SUB GREAT(A,B,C)
IF A>B AND A>C THEN
PRINT"GREATEST NUMBER IS";A
ELSEIF B>A AND B>C THEN
PRINT"GREATEST NUMBER IS";B
ELSE
PRINT"GREATEST NUMBER IS";C
END IF
END SUB
CLS
INPUT"ENTER FIRST NUMBER";A
INPUT"ENTER SECOND NUMBER";B
INPUT"ENTER THIRD NUMBER";C
CALL GREAT(A,B,C)
SUB
SUB GREAT(A,B,C)
IF A>B AND A>C THEN
PRINT"GREATEST NUMBER IS";A
ELSEIF B>A AND B>C THEN
PRINT"GREATEST NUMBER IS";B
ELSE
PRINT"GREATEST NUMBER IS";C
END IF
END SUB
2) Program to find area of box using FUNCTION
DECLARE FUNCTION AREA(L,B,H)
CLS
INPUT"ENTER LENGTH";L
INPUT"ENTER BREADTH";B
INPUT"ENTER HEIGHT";H
PRINT"AREA OF BOX=";AREA(L,B,H)
END
FUNCTION AREA(L,B,H)
A=2*(L*B+B*H+L*H)
AREA=A
END FUNCTION
3) Program to find area if 4 walls using FUNCTION
DECLARE FUNCTION AREA(L,B,H)
CLS
INPUT"ENTER LENGTH";L
INPUT"ENTER BREADTH";B
INPUT"ENTER HEIGHT";H
AR=AREA
PRINT"Area of 4 walls=";AREA(L,B,H)
END
FUNCTION AREA(L,B,H)
AREA=2*H*(L+B)
END FUNCTION
CLS
INPUT"ENTER LENGTH";L
INPUT"ENTER BREADTH";B
INPUT"ENTER HEIGHT";H
AR=AREA
PRINT"Area of 4 walls=";AREA(L,B,H)
END
FUNCTION AREA(L,B,H)
AREA=2*H*(L+B)
END FUNCTION
4) DECLARE SUB CIRCLE(R)
INPUT"ENTER RADIUS";R
CALL CIRCLE(R)
END
SUB CIRCLE(R)
C=2*22/7*R
PRINT"CIRCUMFERENCE OF CIRCLE=";C
END SUB
CLS
INPUT"ENTER LENGTH";L
INPUT"ENTER BREADTH";B
INPUT"ENTER HEIGHT";H
PRINT"VOLUME OF BOX=";VOL(L,B,H)
END
FUNCTION VOL(L,B,H)
V=L*B*H
VOL=V
END FUNCTION
CLS
INPUT"ENTER ANY WORD";N$
CALL DISPLAY(N$)
END
SUB DISPLAY(N$)
FOR I= 1 TO LEN(N$)
B$= MID$(N$,I,1)
C$= UCASE$(B$)
IF C$="A" OR C$="E" OR C$="I" OR C$="O" OR C$="U" THEN D$=D$+B$
NEXT I
PRINT"VOWELS="D$
END SUB
CLS
INPUT"ENTER ACCELERATION",A
INPUT"ENTER INITIAL VELOCITY";U
INPUT"ENTER TIME";T
PRINT"DISTANCE TRAVELLED=";DISTANCE(A,U,T)
END
FUNCTION DISTANCE(A,U,T)
S=U*T+1/2*A*T^2
DISTANCE=S
END FUNCTION
Program to find area if 4 walls using FUNCTION
CLS
INPUT"ENTER LENGTH";L
INPUT"ENTER BREADTH";B
INPUT"ENTER HEIGHT";H
AR=AREA
PRINT"Area of 4 walls=";AREA(L,B,H)
END
FUNCTION AREA(L,B,H)
AREA=2*H*(L+B)
END FUNCTION
Program to find circumference of circle using SUB
INPUT"ENTER RADIUS";R
CALL CIRCLE(R)
END
SUB CIRCLE(R)
C=2*22/7*R
PRINT"CIRCUMFERENCE OF CIRCLE=";C
END SUB
Program to find whether the given no. is divisible by 13 or not using SUB
Program to find volume of box using FUNCTION
CLS
INPUT"ENTER LENGTH";L
INPUT"ENTER BREADTH";B
INPUT"ENTER HEIGHT";H
PRINT"VOLUME OF BOX=";VOL(L,B,H)
END
FUNCTION VOL(L,B,H)
V=L*B*H
VOL=V
END FUNCTION
Program to print only vowels from given word using SUB
CLS
INPUT"ENTER ANY WORD";N$
CALL DISPLAY(N$)
END
SUB DISPLAY(N$)
FOR I= 1 TO LEN(N$)
B$= MID$(N$,I,1)
C$= UCASE$(B$)
IF C$="A" OR C$="E" OR C$="I" OR C$="O" OR C$="U" THEN D$=D$+B$
NEXT I
PRINT"VOWELS="D$
END SUB
CLS
INPUT"ENTER ANY WORD";N$
CALL DISPLAY(N$)
END
SUB DISPLAY(N$)
FOR I= 1 TO LEN(N$)
B$= MID$(N$,I,1)
C$= UCASE$(B$)
IF C$="A" OR C$="E" OR C$="I" OR C$="O" OR C$="U" THEN D$=D$+B$
NEXT I
PRINT"VOWELS="D$
END SUB
Program to calculate distance using FUNCTION
CLS
INPUT"ENTER ACCELERATION",A
INPUT"ENTER INITIAL VELOCITY";U
INPUT"ENTER TIME";T
PRINT"DISTANCE TRAVELLED=";DISTANCE(A,U,T)
END
FUNCTION DISTANCE(A,U,T)
S=U*T+1/2*A*T^2
DISTANCE=S
END FUNCTION
Program to print simple interest using FUNCTION
CLS
INPUT"ENTER PRINCIPLE";P
INPUT"ENTER TIME"T
INPUT"ENTER RATE";R
PRINT"Simple Interest=";SIMPLE(P,T,R)
END
FUNCTION SIMPLE(P,T,R)
S=(P*T*R)/100
SIMPLE=S
END FUNCTION
Program to check whether the given word is palindrome string or not using FUNCTION
CLS
INPUT"ENTER ANY WORD";N$
P$=PAL$(N$)
IF N$=P$ THEN
PRINT"The given word is palindrome"
ELSE
PRINT"The given word is not palindrome"
END
FUNCTION PAL$(N$)
FOR I= LEN$(N$) TO 1 STEP -1
B$= MID$(N$,I,1)
C$=C$+B$
NEXT I
PAL$=C$
END FUNCITON
Program to check whether the given no is armstrong number or not using FUNCTION
CLS
INPUT"ENTER ANY NUMBER";N
A=P
P=ARM
IF A=P THEN
PRINT"The given no is armstrong"
ELSE
PRINT"The given no is not armstrong"
END IF
END
FUNCTION ARM(N)
S=0
WHILE N<>0
R=N MOD 10
S=S+R^3
N=N\10
WEND
ARM=S
END FUNCTION
Program to find the factors of a number using FUNCTION
CLS
INPUT"ENTER ANY NUMBER";N
PRINT"FACTOR=";FACT(N)
END
FUNCTION FACT(N)
FOR I= 1 TO N
IF N MOD I=0 THEN
PRINT I
NEXT I
END FUNCTION