QBasic Programming

WAP to input any number and check whether the given no. is Armstrong or not

CLS
INPUT "ENTER ANY NUMBER"; N
A = N
S = 0
WHILE N < > 0
R = N MOD 10
S = S + R ^ 3
N = N \ 10
WEND
IF A = S THEN
PRINT A; "IS ARMSTRONG"
ELSE
PRINT A; "IS NOT ARMSTRONG"
END IF
END

USING SUB PROCEDURE

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

SUB ARM (N)
A = N
S = 0
WHILE N < > 0
R = N MOD 10
S = S  + R ^ 3
N = N \ 10
WEND
IF A = S THEN
PRINT A; "IS ARMSTRONG NUMBER"
ELSE
PRINT A; "IS NOT ARMSTRONG NUMBER"
END IF
END SUB
 USING FUNCTION PROCEDURE

DECLARE FUNCTION ARM (N)
CLS
INPUT "ENTER ANY NUMBER"; N
A=N
AR = ARM (N)
IF A = AR THEN
PRINT A; "IS ARMSTRONG NUMBER"
ELSE
PRINT A; "IS NOT ARMSTRONG NUMBER"
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

WAP to display all palindrome numbers from 1 to 200 (Prev Lesson)
(Next Lesson) WAP to display first 5 Armstrong numbers
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!