73.5k views
5 votes
To print factorial of any
input number
QBASIC​

1 Answer

3 votes

Answer:

The program in QBasic is as follows;

PRINT "Number: "

INPUT N

LET FACT = 1

FOR I = 1 TO N

FACT = FACT * I

NEXT I

PRINT FACT

END

Step-by-step explanation:

This prompts user for number

PRINT "Number: "

This accepts input from the user

INPUT N

This initializes the factorial to 1

LET FACT = 1

This iterates through the number the user inputs and calculates its factorial

FOR I = 1 TO N

FACT = FACT * I

NEXT I

This prints the factorial

PRINT FACT

The program ends here

END

User ALearningLady
by
7.9k points

Related questions