Created
September 30, 2012 07:19
-
-
Save svineet/3806145 to your computer and use it in GitHub Desktop.
QBASIC Code for a simple calculator program
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CLS | |
SCREEN 13 | |
PRINT "CALCULATOR-" | |
PRINT "ENTER YOUR EXPRESSION" | |
PRINT "EXAMPLE-58 * 20" | |
PRINT "THE TERMS SHOULD BE SEPARATED BY SPACE OR ERROR WILL OCCUR" | |
INPUT "ENTER YOUR EXPRESSION-"; EXP$ | |
EXP$ = EXP$ + " " | |
INDEX = 1 | |
DIM TERMS(3) AS INTEGER | |
FOR I = 1 TO LEN(EXP$) | |
CURRENTTOKEN$ = MID$(EXP$, I, 1) | |
IF CURRENTTOKEN$ = " " THEN | |
IF INDEX = 2 AND OPERATION$ = "" THEN | |
OPERATION$ = TERMCURRENT$ | |
ELSE | |
TERMS(INDEX) = VAL(TERMCURRENT$) | |
INDEX = INDEX + 1 | |
END IF | |
TERMCURRENT$ = "" | |
ELSE | |
TERMCURRENT$ = TERMCURRENT$ + CURRENTTOKEN$ | |
END IF | |
NEXT I | |
SELECT CASE OPERATION$ | |
CASE "+" | |
R = TERMS(1) + TERMS(2) | |
CASE "*" | |
R = TERMS(1) * TERMS(2) | |
CASE "-" | |
R = TERMS(1) - TERMS(2) | |
CASE "/" | |
R = TERMS(1) / TERMS(2) | |
CASE "%" | |
R = TERMS(1) MOD TERMS(2) | |
CASE "^" | |
R = TERMS(1) ^ TERMS(2) | |
END SELECT | |
PRINT TERMS(1); OPERATION$; TERMS(2); "="; R |
how do i fix the error in line 31
illegal between select case and case
how do i fix the error in line 31 illegal between select case and case
did u put a space between two characters?
WRONG : 2+2
RIGHT : 2 + 2
CLS
INPUT "ENTER ANY NUMBER"; N
A N
S = 0
WHILE N <> 0
RN MOD 10
S S 10+ R
N = N \ 10
WEND
IF A = S THEN
PRINT A; "IS PALINDROME"
ELSE
PRINT A; "IS NOT PALINDROME"
END IF
END
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
31 SELECT CASE OPERATION$
this is trowing error, illegal between select case and case
what is the problem
i am a beginner