Computer for SEE and NEB

It is a complete SEE and NEB solution for computer science. It includes Computer Fundamentals, Database (SQL), Programming in C QBASIC, CSS, JavaScript, and PHP for beginners.

Breaking

Post Top Ad

Your Ad Spot

Thursday, December 1, 2022

QBASIC program to display the difference of input two numbers

 QBASIC Program to Display the Difference of Input Two Numbers

 



Are you interested in programming? Are you looking for a way to display the difference of two input numbers in QBASIC? If so, then this article is for you! In this article, we will explore how to create a QBASIC program that calculates the difference of two input numbers and displays the result. We will cover the basic syntax of QBASIC and walk through the step-by-step process of creating this program.

Introduction to QBASIC


QBASIC is an interpreted programming language developed by Microsoft. It is a simple yet powerful language that is easy to learn and use. QBASIC provides a structured programming environment with the ability to create programs using simple statements and flow control structures. It also provides support for subroutines, functions, and modules.

Setting up the QBASIC Environment

Before we start coding, we need to set up the QBASIC environment. QBASIC is a part of MS-DOS, which means that we need to install MS-DOS on our computer first. Once MS-DOS is installed, we can start QBASIC by typing "QBASIC" in the command prompt.

Creating the Program

Now that we have set up the QBASIC environment, let's start coding! The first step is to declare the variables that we will be using in our program. In this case, we will be using two variables to store the input numbers and one variable to store the result.


Explanation of the above code:

The CLS statement clears the screen before displaying the output. The INPUT statements prompt the user to enter two numbers. The difference is calculated and stored in the variable "diff". Finally, the result is displayed using the PRINT statement. The program ends with the END statement.

We can solve the same problem by using SUB and FUNCTION procedures:





Output:





Conclusion


In this article, we have explored how to create a QBASIC program that display the difference of input two input numbers and displays the result. We have covered the basic syntax of QBASIC and walked through the step-by-step process of creating this program. QBASIC is a simple yet powerful language that is easy to learn and use. We hope that this article has helped you to get started with QBASIC programming!

FAQs


1. What is QBASIC? 
Ans: QBASIC is an interpreted programming language developed by Microsoft.


2. What is the difference between QBASIC and QuickBASIC? 
Ans: QBASIC is a subset of QuickBASIC. QuickBASIC is a more powerful language with support for more advanced features.


3. Can I use QBASIC on modern operating systems? 
Ans: QBASIC is no longer supported on modern operating systems, but it can still be used on older versions of Windows and in DOS emulators.


4. What other programming languages are similar to QBASIC? 
Ans: BASIC, GW-BASIC, and QuickBASIC are similar programming languages to QBASIC.


5. Where can I learn more about QBASIC programming? 
Ans: There are many resources available online for learning QBASIC programming, including tutorials, forums, and documentation.

No comments:

Post a Comment

Post Top Ad

Your Ad Spot

Pages