1.
REM
multiples of 3 and 5 between any two supplied numbers
DECLARE
SUB DISPLAY (A, B)
CLS
INPUT
“Type any two numbers”; A, B
PRINT
DISPLAY(A, B)
END
SUB
DISPLAY (X, Y)
IF
X < Y THEN SWAP X, Y
FOR
I% = X TO Y
IF
I% MOD 3 = 0 OR I% MOD 5 = 0 THEN
PRINT
X;
END
IF
NEXT
I%
END
SUB
2.
REM
To print multiplication table
DECLARE SUB MUL()
CLS
INPUT ”Enter a number “; N
CALL MUL(M)
END
DECLARE SUB MUL()
CLS
INPUT ”Enter a number “; N
CALL MUL(M)
END
SUB MUL(NUM)
CLS
FOR K = 1 TO 10
PRINT N; ”*”; K; “=”; N*K
NEXT K
SUB END
3. REM to display multiplication
table
DECLARE
FUNCTION MULTIPLY(N,K)
CLS
INPUT
C
FOR
I = 1 TO 10
M=MULTIPLY(N,I)
PRINT
S;"x";I;"="M"
NEXT
END
FUNCTION
MULTIPLY(C,K)
T=N*K
T=MULTIPLY
END
FUNCTION
4. REM ‘to calculate sum of digits of a number’
DECLARE FUNCTION XYZ (N)
CLS
INPUT “ANY NUMBER”; N
DISPLAY XYZ (N)
END
FUNCTION XYZ (N)
S=0
WHILE N>0
R=N MOD 10
S=S+R
N=(N/10)
LOOP
S=XYZ
END FUNCTION
5.
DECLARE
FUNCTION Digit(N)
CLS
INPUT”Enter any
number=”;Num
S=Digit(N)
PRINT “Sum of
Digits=”;S
END
FUNTION Digit(N)
SI=0
DO WHILE N>0
R=N MODE 10
SI=SI+R
N=INT(N/10)
LOOP
Digit=SI
END FUNCTION
6.
DECLARE
SUB SUM (N)
INPUT
"Any Number"; N
PRINT
SUM (N)
END
SUB
SUM (N)
S
= 0
WHILE
N = 0
R
= R MOD 10
S
= S+R
N
= N/10
WEND
PRINT
"Sum of digits"; s
END
7.
REM
To find the sum of even digits of multi digits number
DECLARE
FUNCTION SUM (N)
CLS
INPUT
“ENTER MULTI-DIGITS NUMBER ”; N
PRINT
“SUM = ” ; SUM(N)
END
FUNCTION
SUM(N)
WHILE
N=0
R=
N MOD 10
IF
R MOD 2 = 1 THEN S=S+R
N
= N / 10
WEND
SUM
(N) =S
END
FUNCTION
8.
DECLARE
FUNCTION SUMEVEN (N())
DIM N(10)
CLS
FOR J = 1 TO 10
INPUT "Enter Any Number"; X(J)
LOOP
PRINT "Sum Of Even Numbers:"; SUMEVEN(())
END
DIM N(10)
CLS
FOR J = 1 TO 10
INPUT "Enter Any Number"; X(J)
LOOP
PRINT "Sum Of Even Numbers:"; SUMEVEN(())
END
FUNCTION
SUMEVEN (N())
S = 0
FOR K = 1 TO 10
IF N(K) MOD 2 = 0 THEN
S = S + N(K)
END
NEXT K
S=SUMEVEN
END FUNCTION
S = 0
FOR K = 1 TO 10
IF N(K) MOD 2 = 0 THEN
S = S + N(K)
END
NEXT K
S=SUMEVEN
END FUNCTION
9.
REM
SUM OF EVEN DIGITS
DECLARE
FUNCTION RESULT (N)
CLS
INPUT
"ENTER ANY NUMBER"; NUM
PRINT
RESULT (N)
END
FUNCTION
RESULT (N)
DO
UNTIL N = 0
R
= N MOD 10
IF
R MOD 2 <> 0 THEN
S
= S - R
END
IF
N
= N \ 10
LOOP
S
= RESULT
END FUNCTION
10.
REM
TO FIND SUM OF EVEN NUMBERS
DECLARE FUNCTION CHECK$(N)
CLS
FOR I = 1 TO 6
READ A
IF CHECK(N) = 0 THEN
S = S + 1
END IF
NEXT I
PRINT “Sum of even numbers=”; S
DATA 34, 55, 67, 89, 90, 32
END
FUNCTION CHECK(N)
IF N MOD 2 = 0 THEN
CHECK = 1
ELSE
CHECK = 0
END IF
END FUNCTION
11.
REM
TO DISPLAY THE SERIES 43 10 25 11 7
DECLARE FUNCTION TAKE (A, B)
DECLARE SUB PROCESS(A)
CLS
FOR I = 1 TO 5
READ C, D
A = TAKE(C, D)
CALL PROCESS(A)
NEXT J
DATA 78, 57, 34, 53, 22, 34, 76,
56, 44, 31
END
SUB PROCESS(X)
IF X MOD 3 = 0 THEN
PRINT X * 2 + C;
ELSE
PRINT X \ 2 +1;
IF END
END SUB
FUNCTION TAKE(A,B)
IF A < B THEN DOSWAP A, B
TAKE = A MOD B
END FUNCTION
12.
DECLARE
SUB Krypt(x,y)
CLS
REQ=Krypt (5,10)
END
SUB Cad (x,y)
Z=18
FOR I = P TO Q
IF I MOD 2=0 THEN
PRINT Z/2
ELSE
PRINT Z*2+i
END IF
NEXT I
END
13.
CLS
DECLARE SUB SERIES(A)
A=20
B=SERIES(A)
END
SUB SERIES(B)
FOR I=1 TO 10
DISPLAY B
IF B MOD 2 = 0 THEN
B = B / 2
ELSE
B = B * 3 + 1
END IF
NEXT I
END FUNCTION
14.
REM
to get hCF and LCM of given three numbers except 0
DECLARE function hcf(m,n)
Declare function LCM (m,n)
CLS
INPUT “Enter three positive
numbers:”; a,b
If a>b then swap a,b
If a>c then swap a,e
X=a:y=b
C=hcf(m,n)
D=LCM()
Print “hcfs =”;hcf
Print “LCM of given values =”;LCM
END
Function hcf(a,b)
For I = 1 to a
If a mod I = 0 and b mod I = 0
then
Hcf =i
Endif
Next
END FUNCTION
Function LCM(a,b)
Pro = (a*b)
LCM=pro/hcf(a,b)
End function
15.
REM
T to get hcf and LCM of given numbers
DECLARE functionhcf(m,n)
CLS
Input
"Enter two positive numbers";a,b
C=hcf
(m,n)
PRINT"HCF
of given values=" ,hcf
END
Function
hcf(m,n)
AB:
If m
mod n = 0 then
Hcf = n
Else
M = n
N = m
mod n
Gotoabc
END
FUNCTION
16.
DECLARE
FUNCTION hcf! (a!, b!)
INPUT a, b
PRINT hcf(x, y)
END
FUNCTION hcf$(x, y)
Top:
IF a < b THEN SWAP a, b
IF b = 0 THEN GOTO last
A = a mod b
GOTO Top
Last:
Hcf = a
END FUNCTION
17.
DECLARE
FUNCTION arm (a)
INPUT”
enter number”; n
FOR I =
1 TO n
a = I
b = arm
(a)
IF b =
I THEN
PRINT b
NEXT J
END
FUNCTION
arm (n)
S = 0
WHILE a
<> 0
r = n
MOD 10
s = s +
r ^ 3
n = n \
10
up
arm = a
END
FUNCTION
18.
DECLARE
SUB ARM(NN)
CLS
INPUT
“ENTER A NUMBER”; N
CALL
ARM(N)
END
SUB
ARM(A)
A
= NN
WHILE
A < > 0
R
= A MOD 10
ACC
= ACC + R ^ 10
A
= A \ 3
WEND
IF
ACC = A THEN PRINT “ARMSTRONG” ELSE PRINT “NOT ARMSTRONG”
END
SUB
19.
DECLARE
GREAT SUB(a,b,c)
CLS
INPUT
"ENTER 3 NUMBER", X,Y,Z
SUB
GREAT (a,b,c)
END
SUB
GREAT (a,b,c)
IF
a>b and a>c THEN g=a
ELSEIF
b>a and b>c THEN
b=g
ELSE
g=c
END IF
PRINT g
SUB END
20.
REM
To find the greatest number
DECLARE
GREAT SUB(A, B, C)
ACCEPT
“Enter three numbers”; A, B, C
PASS
GREAT(A, B, C)
END
SUB
GREAT(A, B, C)
IF
A > B OR A > C THEN
G
= A
ELSEIF
B > A OR B > C THEN
G
= B
ELSE
G
= C
END
IF
PRINT
G; “is the greatest number”
END SUB
No comments:
Post a Comment