A complete code for making calculator//simple Qbasic Code

Use this code to make a calculator in minutes
The program code is in qbasic language_____________ ______________

Code........................................................below👇👇👇👇





PRINT "************ BASIC CALCULATOR ************"

CLS
PRINT "Basic Calculator"
PRINT "----------------"
PRINT

DO
    PRINT "1. Addition"
    PRINT "2. Subtraction"
    PRINT "3. Multiplication"
    PRINT "4. Division"
    PRINT "5. Exit"
    PRINT
    INPUT "Enter your choice (1-5): "; choice$

    SELECT CASE choice$
        CASE "1"
            INPUT "Enter the first number: "; num1
            INPUT "Enter the second number: "; num2
            result = num1 + num2
            PRINT "Result: "; result

        CASE "2"
            INPUT "Enter the first number: "; num1
            INPUT "Enter the second number: "; num2
            result = num1 - num2
            PRINT "Result: "; result

        CASE "3"
            INPUT "Enter the first number: "; num1
            INPUT "Enter the second number: "; num2
            result = num1 * num2
            PRINT "Result: "; result

        CASE "4"
            INPUT "Enter the first number: "; num1
            INPUT "Enter the second number: "; num2
            IF num2 = 0 THEN
                PRINT "Error: Division by zero!"
            ELSE
                result = num1 / num2
                PRINT "Result: "; result
            END IF

        CASE "5"
            PRINT "Exiting..."
            END

        CASE ELSE
            PRINT "Invalid choice! Please enter a number from 1 to 5."
    END SELECT

    PRINT
LOOP

This program displays a menu of options for performing addition, subtraction, multiplication, and division. It also includes an option to exit the calculator. The user can enter their choice, and then the program prompts for the required numbers to perform the selected operation. The result is then displayed. The program continues to run in a loop until the user chooses to exit.


About the Author

programmer,blogger,webdesigner,youtuber

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.