# QBasic Program to Print Multiplication Table of a Given Number

Write a program to print multiplication table of a given number in QBasic.

For example,

```Input
5
Output
5 * 1 = 5
5 * 2 = 10
5 * 3 = 15
5 * 4 = 20
5 * 5 = 25
5 * 6 = 30
5 * 7 = 35
5 * 8 = 40
5 * 9 = 45
5 * 10 = 50```

Steps

• First, the program asks the user to enter a number. Let the input be n.
• Loop we from i = 1 to 10 and print n * i.

QBasic Program to Print Multiplication Table

``````CLS
INPUT "Enter a Number: ", n
FOR i = 1 TO 10
PRINT n;" * ";i;" = ";n*i
NEXT i
END``````

QBasic Program to Print Multiplication Table – Using Subroutine

``````DECLARE SUB print_table(n)

CLS
INPUT "Enter a Number: ", n
print_table(n)
END

SUB print_table(n)
FOR i = 1 TO 10
PRINT n;" * ";i;" = ";n*i
NEXT i
END SUB``````

QBasic Program to Print Multiplication Table – Using Function

``````DECLARE FUNCTION print_table(n)

CLS
INPUT "Enter a Number: ", n
print_table(n)
END

FUNCTION print_table(n)
FOR i = 1 TO 10
PRINT n;" * ";i;" = ";n*i
NEXT i
END FUNCTION``````

QBasic Program to Print Multiplication Table – Using Recursion

``````DECLARE FUNCTION print_table(n, i)

CLS
INPUT "Enter a Number: ", n
print_table(n, 1)
END

FUNCTION print_table(n, i)
IF i <= 10 THEN
PRINT n;" * ";i;" = ";n*i
print_table(n,i+1)
END IF
END FUNCTION``````