QBasic Programming

WAP to input any number and display the factorial of a given number

CLS
INPUT "ENTER ANY NUMBER"; N
F = 1
FOR I = 1 TO N
F = F * I
NEXT I
PRINT "FACTORIAL ="; F
END

USING SUB PROCEDURE

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

SUB FACT (N)
F = 1
FOR I = 1 TO N
F = F * I
NEXT I
PRINT "FACTORIAL ="; F
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION FACT (N)
CLS
INPUT "ENTER ANY NUMBER"; N
PRINT "FACTORIAL ="; FACT (N)
END

FUNCTION FACT (N)
F = 1
FOR I = 1 TO N
F = F * I
NEXT I
FACT = F
END FUNCTION

WAP to input any number and find sum of factors (Prev Lesson)
(Next Lesson) WAP to input any number and display the prime factorial of a given number
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!