QBasic Programming

WAP to display all Armstrong numbers from 1 to 500

CLS
N = 1
FOR I = 1 TO 500
A = N
S = 0
WHILE A <> 0
R = A MOD 10
S = S + R ^ 3
A = A \ 10
WEND
IF N = S THEN PRINT N,
N = N + 1
NEXT I
END

USING SUB PROCEDURE

DECLARE SUB ARM ( )
CLS
CALL ARM
END

SUB ARM
N = 1
FOR I = 1 TO 500
A = N
S = 0
WHILE A <> 0
R = A MOD 10
S = S + R ^ 3
A = A \ 10
WEND
IF N = S THEN PRINT N,
N = N + 1
NEXT I
END SUB

WAP to display first 5 Armstrong numbers (Prev Lesson)
(Next Lesson) WAP to input number and check whether the given no. is prime or composite
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!