PERFECT NUMBER, PERFECT SQUARE NUMBER, MULTIPLICATION NUMBER, HCF AND LCM QBASIC PROGRAMS

136. WAP TO CHECK WHETHER THE INPUT NUMBER IS PERFECT NUMBER OR NOT.


CLS
INPUT "ENTER ANY NUMBER"; N
S = 0
FOR I = 1 TO N - 1
IF N MOD I = 0 THEN S = S + I
NEXT I
IF S = N THEN
PRINT "PERFECT NUMBER"
ELSE
PRINT "NOT PERFECT NUMBER"
END IF
END

USING SUB PROCEDURE

DECLARE SUB PERFECT (N)
CLS
INPUT "ENTER ANY NUMBER"; N
CALL PERFECT (N)
END

SUB PERFECT (N)
S = 0
FOR I = 1 TO N - 1
IF N MOD I = 0 THEN S = S + I
NEXT I
IF S = N THEN
PRINT "PERFECT NUMBER"
ELSE
PRINT "NOT PERFECT NUMBER"
END IF
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION PERFECT (N)
CLS
INPUT "ENTER ANY NUMBER"; N
PR = PERFECT (N)
IF PR = N THEN
PRINT "PERFECT NUMBER"
ELSE
PRINT "NOT PERFECT NUMBER"
END IF
END
FUNCTION PERFECT (N)
S = 0
FOR I = 1 TO N - 1
IF N MOD I = 0 THEN S = S + I
NEXT I
PERFECT = S
END FUNCTION

137. WAP TO CHECK WHETHER THE INPUT NUMBER IS PERFECT SQUARE NUMBER OR NOT.

CLS
INPUT "ENTER ANY NUMBER"; N
S = SQR(N)
IF S = INT(S) THEN
PRINT "PERFECT SQUARE"
ELSE
PRINT "NOT PERFECT SQUARE"
END IF
END

USING SUB PROCEDURE

DECLARE SUB PERFECT (N)
CLS
INPUT "ENTER ANY NUMBER"; N
CALL PERFECT (N)
END

SUB PERFECT (N)
S = SQR(N)
IF S = INT(S) THEN
PRINT "PERFECT SQUARE"
ELSE
PRINT "NOT PERFECT SQUARE"
END IF
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION PERFECT (S)
CLS
INPUT "ENTER ANY NUMBER"; N
S = SQR(N)
PR = PERFECT (S)
IF PR = S THEN
PRINT "PERFECT SQUARE"
ELSE
PRINT "NOT PERFECT SQUARE"
END IF
END
FUNCTION PERFECT (S)
PERFECT = INT (S)
END FUNCTION



137. WAP TO DISPLAY MULTIPLICATION TABLE OF A GIVEN NUMBER.

CLS
INPUT "ENTER ANY NUMBER"; N
FOR I = 1 TO 10
PRINT N; "X"; I; "="; N * I
NEXT I
END

USING SUB PROCEDURE

DECLARE SUB MUL (N)
CLS
INPUT "ENTER ANY NUMBER"; N
CALL MUL (N)
END

SUB MUL (N)
FOR I = 1 TO 10
PRINT N; "X"; I; "="; N * I
NEXT I
END SUB

USING FUNCTION  PROCEDURE

DECLARE FUNCTION MUL (N)
CLS
INPUT "ENTER ANY NUMBER"; N
M = MUL(N)
END

FUNCTION MUL (N)
FOR I = 1 TO 10
PRINT N; "X"; I; "="; N * I
NEXT I
END FUNCTION


137. WAP TO DISPLAY H.C.F AND L.C.M OF A GIVEN ANY TWO NUMBERS.

CLS
INPUT "ENTER ANY TWO NUMBERS"; A, B
C = A
D = B
WHILE A MOD B < > 0
T = A MOD B
A = B
B = T
WEND
L = C * D / B
PRINT "H.C.F="; B
PRINT "L.C.M="; L
END




USING SUB PROCEDURE


DECLARE SUB HCFLCM(A, B)
CLS
INPUT "ENTER ANY TWO NUMBERS"; A, B
CALL HCFLCM (A, B)
END

SUB HCFLCM (A, B)
C = A
D = B
WHILE A MOD B < > 0
T = A MOD B
A = B
B = T
WEND
L = C * D / B
PRINT "H.C.F="; B
PRINT "L.C.M="; L
END SUB

USING FUNCTION PROCEDURE


DECLARE FUNCTION HCFLCM(A, B)
CLS
INPUT "ENTER ANY TWO NUMBERS"; A, B
PRINT “L.C.M=”; HCFLCM (A, B)
END

FUNCTION HCFLCM (A, B)
C = A
D = B
WHILE A MOD B < > 0
T = A MOD B
A = B
B = T
WEND
L = C * D / B
PRINT "H.C.F="; B
HCFLCM = L
END FUNCTION



138. WAP TO DISPLAY H.C.F OF A GIVEN ANY TWO NUMBERS.

CLS
INPUT "ENTER ANY TWO NUMBERS"; A, B
WHILE A MOD B < > 0
T = A MOD B
A = B
B = T
WEND
PRINT "H.C.F="; B
END


USING SUB PROCEDURE


DECLARE SUB HCF(A, B)
CLS
INPUT "ENTER ANY TWO NUMBERS"; A, B
CALL HCF (A, B)
END

SUB HCF (A, B)
WHILE A MOD B < > 0
T = A MOD B
A = B
B = T
WEND
PRINT "H.C.F="; B
END SUB

USING FUNCTION PROCEDURE


DECLARE FUNCTION HCF(A, B)
CLS
INPUT "ENTER ANY TWO NUMBERS"; A, B
PRINT “H.C.F=”; HCF (A, B)
END

FUNCTION HCF (A, B)
WHILE A MOD B < > 0
T = A MOD B
A = B
B = T
WEND
HCF = B
END FUNCTION




139. WAP TO DISPLAY L.C.M OF A GIVEN ANY TWO NUMBERS.

CLS
INPUT "ENTER ANY TWO NUMBERS"; A, B
C = A
D = B
WHILE A MOD B < > 0
T = A MOD B
A = B
B = T
WEND
L = C * D / B
PRINT "L.C.M="; L
END

USING SUB PROCEDURE


DECLARE SUB LCM(A, B)
CLS
INPUT "ENTER ANY TWO NUMBERS"; A, B
CALL LCM (A, B)
END

SUB LCM (A, B)
C = A
D = B
WHILE A MOD B < > 0
T = A MOD B
A = B
B = T
WEND
L = C * D / B
PRINT "L.C.M="; L
END SUB

USING FUNCTION PROCEDURE


DECLARE FUNCTION LCM(A, B)
CLS
INPUT "ENTER ANY TWO NUMBERS"; A, B
PRINT “L.C.M=”; LCM (A, B)
END

FUNCTION LCM (A, B)
C = A
D = B
WHILE A MOD B < > 0
T = A MOD B
A = B
B = T
WEND
L = C * D / B
LCM = L
END FUNCTION

Comments

Blog27999 said…
As reported by Stanford Medical, It is in fact the ONLY reason women in this country live 10 years longer and weigh 42 lbs lighter than us.

(And realistically, it really has NOTHING to do with genetics or some hard exercise and EVERYTHING related to "HOW" they eat.)

BTW, I said "HOW", not "what"...

Tap this link to discover if this brief quiz can help you decipher your real weight loss possibility

Popular posts from this blog

PROGRAM TO FIND SQUARE, CUBE, SQUARE ROOT AND CUBE ROOT OF GIVEN NUMBER

PROGRAM TO DISPLAY SUM, PRODUCT, DIFFERENCE AND PRODUCT OF TWO / THREE NUMBERS

PALINDROME AND ARMSTRONG PROGRAMS