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 calculate and display the sum of input two numbers


QBASIC program to calculate and display the sum of input two numbers





Introduction:


Are you interested in learning how to write a QBASIC program to calculate and display the sum of two input numbers? If so, you've come to the right place! In this article, we'll walk you through the process of creating a simple QBASIC program to calculate and display the sum of input two numbers

QBASIC is an old but powerful programming language that can be used to create a wide range of programs. If you're new to programming, QBASIC is a great language to start with as it is easy to learn and understand. So, let's get started and learn how to create a QBASIC program to calculate and display the sum of two input numbers.

Writing the QBASIC Program

To write the QBASIC program to calculate and display the sum of two input numbers, follow these steps:

Step 1: Define the Variables
Step 2: Get Input from the User
Step 3: Calculate the sum
Step 4: Display the sum



Complete coding



Explanation of Code


  • The first line of the code, "CLS", clears the screen so that the program can start with a clean slate.
  • The next two lines of code use the "INPUT" statement to prompt the user to enter two numbers. The first input statement asks the user to enter the first number, and the second input statement asks the user to enter the second number. The semicolon (;) after each input statement means that the input will be displayed on the same line as the prompt.
  • The third line of code calculates the sum of the two input numbers and stores it in the variable "sum". The plus sign (+) is the addition operator in QBASIC, and it is used to add the two numbers together.
  • The final line of code uses the "PRINT" statement to display the sum to the user. The semicolon (;) after "Sum of two numbers:" means that the sum will be displayed on the same line as the prompt.
  • The last line of the code, "END", indicates the end of the program.

The above program can also be solved by using SUB and FUNCTION procedure





Output:






Conclusion:


In conclusion, learning QBASIC programming language can be a great way to develop fundamental programming skills. In this tutorial, we learned how to write a simple QBASIC program to calculate and display the sum of two input numbers. By following the step-by-step guide and practicing writing the code, anyone can easily understand and implement this program.


FAQ:

Q: What is QBASIC? 
Ans: QBASIC is a programming language that was developed by Microsoft in the early 1980s. It is an easy-to-learn language that is used for writing and running programs on MS-DOS and Windows-based computers.

Q: What is the purpose of this QBASIC program? 
Ans: The purpose of this program is to calculate and display the sum of two input numbers.

Q: Do I need any prior programming experience to write this QBASIC program? 
Ans: No, you do not need any prior programming experience to write this program. The step-by-step guide provided in the tutorial is designed for beginners, and anyone can follow it to write the program.

Q: Can I modify this program to calculate the difference, product, or quotient of two input numbers? 
Ans: Yes, you can modify this program to calculate the difference, product, or quotient of two input numbers. All you need to do is replace the addition operator with the appropriate mathematical operator.

Q: Where can I find more resources to learn QBASIC programming language? 
Ans: There are many online resources available for learning QBASIC programming language, including tutorials, forums, and books. A simple Google search will yield many results that you can use to further your knowledge of QBASIC programming.



No comments:

Post a Comment

Post Top Ad

Your Ad Spot

Pages