Computer Science, asked by vinayak12122008, 3 months ago

how to get hcf of two numbers in qbasic

Answers

Answered by ashumane
4

Answer:

QBasic Programming

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.

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.

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


vinayak12122008: I want something easier. WIthout using commands such as wend and while.
Answered by AadishreePradhan
2

Answer:

CLS

INPUT "Enter the first number"; a

INPUT "Enter the second number"; b

m = a

n = b

WHILE a <> 0

r = b MOD a

b = a

a = r

WEND

l = (m * n) / b

PRINT "HCF is "; b

PRINT "LCM is "; l

END

Similar questions