Q-BASIC PROGRAMS

What is Q-BASIC?

Q-BASIC is a high-level programming language that was developed by Microsoft as a simplified version of the BASIC programming language. It was first introduced in 1985 as a part of MS-DOS, an operating system for IBM-compatible personal computers.

Q-BASIC (which stands for “Quick Beginner’s All-purpose Symbolic Instruction Code”) was designed to be easy to learn and use, making it suitable for beginners and hobbyist programmers. It provides a simple syntax and a set of commands that allow users to write programs for various purposes, including mathematical calculations, text processing, graphics, and more.

Q-BASIC programs are composed of a series of statements that instruct the computer on what actions to perform. These statements can include commands for input and output, mathematical operations, conditional branching (if-then-else statements), loops (for-next and do-while loops), and subroutines or functions.

Q-BASIC also provides features for handling user input, displaying output on the screen, and working with variables to store and manipulate data. It has built-in functions and libraries for common tasks, such as string manipulation, file handling, and graphics.

Overall, Q-BASIC is a beginner-friendly programming language that allows users to write simple programs to perform various tasks. It served as an entry point for many programmers, helping them develop fundamental programming skills before moving on to more advanced languages.

Examples of Q-BASIC programs:

1. Hello World:

PRINT “Hello, World!
This program simply prints the text “Hello, World!” to the screen.

2. Addition:

INPUT “Enter the first number: “, num1
INPUT “Enter the second number: “, num2
sum = num1 + num2
PRINT “The sum is: “; sum

This program asks the user to enter two numbers, adds them together, and then prints the sum.

3. Fibonacci Series:

n = 10 ‘ Number of terms in the series
a = 0
b = 1
PRINT “Fibonacci Series:”
PRINT a
PRINT b
FOR i = 3 TO n
c = a + b
PRINT c
a = b
b = c
NEXT i

This program generates and prints the first 10 terms of the Fibonacci series.

4. Factorial:

INPUT “Enter a number: “, num
factorial = 1
FOR i = 1 TO num
factorial = factorial * i
NEXT i
PRINT “The factorial of “; num; ” is: “; factorial

This program calculates and prints the factorial of a given number.

5. Simple Calculator:

INPUT “Enter the first number: “, num1
INPUT “Enter the second number: “, num2
INPUT “Enter the operation (+, -, *, /): “, operation
IF operation = “+” THEN
result = num1 + num2
ELSEIF operation = “-” THEN
result = num1 – num2
ELSEIF operation = “*” THEN
result = num1 * num2
ELSEIF operation = “/” THEN
result = num1 / num2
ELSE
PRINT “Invalid operation”
END
ENDIF
PRINT “The result is: “; result

This program takes two numbers and an operation from the user (+, -, *, /) and performs the calculation accordingly.

6) Write a program to enter your name and print it .

CLS

Input ‘Enter you name’;n$

Print ‘The name is’;n$

End

7) Write a program to enter your name, city, country, age and print them.

CLS

Input ” Enter the name “;N$

Input ” Enter the city”;C$

Input ” Enter the country”;CO$

Input ” Enter the age”;A

15 Places to WIN $10,000
15 Places to WIN $10,000 Cash

Print ” The name is “;N$

Print ” The city is “;C$

Print ” The country is “;CO$

Print ” The age is “;A

End

8) Write a program to find the area of rectangle.

Cls

Input ” enter the length ” ;l

Input ” enter the breadth ” ;b

let A = l*b

Print” the area of rectangle=” ;a

End

9) Write a program to find the area of the triangle.

Cls

Input ” enter the base” ;b

Input ” enter the height” ;h

let T = 1/2*b*h

Print” The area of triangle=” ;T

End

10) Write a program to find the area of the circle.

Cls

Input” Enter the radius ” ;R

Let C=22/7*R^2

Print ” The area of circle =” ;C

End

11) Write a program to find the circumference of the circle.

Cls

Input” Enter the radius ” ;R

Let Circumference=22/7*R*2

Print ” The area of circle =” ;Circumference

End

12) Write a program to find the area of the square.

Cls

Input” Enter the number” ;n

Let square= n^2

Print” The area of square=” ;Square

End

13) Write a program to find the area of the square and cube.

Cls

Input” Enter the number” ;n

Let square= n^2

Let Cube = n^3

Print” The area of square=” ;Square

Print” The area of cube=” ; Cube

End

See also:

BASIC Programming Language

PROGRAMMING LANGUAGE

INTRODUCTION TO DATA PROCESSING

Computer Input devices and Output devices

Data and Information

Leave a Comment

Your email address will not be published. Required fields are marked *

Get Fully Funded Scholarships

Free Visa, Free Scholarship Abroad

           Click Here to Apply

Acadlly