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

Unknown said…
thank you very much for the program you have done ... i am very thankful to tou. Msy gid bless you.
Unknown said…
Veeeeeeeeeeeeeery veeeeeeeeeeeeeery veeeeeeeeeeeeeery nice work.helped me a lot ,love it a lot
anish said…
thank you very much for this programming .It helped me lot.
It helped me a lot!! Tq u☺☺☺
Unknown said…
Wap to accept a multi digit integer and display the product of the digit of the number.
Unknown said…
Thnx for your help
Unknown said…
WRITE A SUB PROCEDURE TO INPUT A NUMBER AND CHECK WHETHER IT IS PERFECT SQUARE OR NOT.
Unknown said…
THANKYOU VERY VERY VERY MUCH. THANKS SA LOT.😊😊😊😊😃😃😃😃😍😍😍☺️☺️☺️🙏🙏🙏🙏🙏🙏🙏
Blogger said…
As stated by Stanford Medical, It's in fact the ONLY reason this country's women get to live 10 years more and weigh on average 42 pounds less than us.

(And realistically, it is not related to genetics or some hard exercise and EVERYTHING to do with "HOW" they are eating.)

BTW, I said "HOW", and not "WHAT"...

Click this link to see if this short test can help you decipher your true weight loss potential

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