QBasic Programming

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

WAP to input any number and display the prime factorial of a given number (Prev Lesson)
(Next Lesson) WAP TO CHECK WHETHER THE INPUT NUMBER IS PERFECT SQUARE NUMBER OR NOT
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!