- HubPages»
- Technology»
- Computers & Software»
- Computer Science & Programming»
- Programming Languages
QBASIC Programs
Most of us know the application software called QBASIC (Quick Beginners’ All-purpose Symbolic Instruction Code), which is a high-level programming language. It is very simple, and is about 200 KB. It is much similar to Command Prompt as you require writing commands in QBASIC too to create and run programs of your own. Those programs are temporary, and can be of any type. You can make any type of Program using the statements and functions (commands).
I am going to share some of the interesting programs I have created, here:
1. Display the number of characters in the word entered by the user
CLS
INPUT “enter your desired word”;N$
PRINT LEN(N$)
END
2. Display the entered word by the user in a “right angled triangle” form
CLS
INPUT “enter a word”;W$
FOR I = 1 to LEN(W$)
PRINT LEFT$(W$, I)
NEXT I
END
3. Display any word entered by the user in reverse
CLS
INPUT “enter a word”;W$
LET A = LEN(W$)
FOR I = 1 to A
A = A – 1
PRINT MID$(W$, A , 1)
NEXT I
END
4. Display the entered word (s) in abbreviated form (esp. full name)
CLS
INPUT “enter your full name”;N$
PRINT LEFT$(N$, 1)
FOR I = 2 to LEN(N$)
LET X$ = MID$(N$, I , 1)
IF X$ = “ ” THEN PRINT MID$(N$, I + 1, 1); “.”;
NEXT I
END
5. Display the entered word in reverse form as well as in a decreasing order from left (inverted right angled triangle + reverse word)
CLS
INPUT “enter the desired word”;A$
FOR I = LEN(A$) to 1 STEP-1
FOR X = I to 1 STEP-1
PRINT MID$(A$, X , 1);
NEXT X
PRINT
NEXT I
END
6. Display the entered word in vertical order
CLS
INPUT “enter a word”;W$
FOR A = 1 to LEN(W$)
PRINT MID$(W$, A , 1)
NEXT A
END
7. Display first and last character of any word entered by the user
CLS
INPUT “enter any word”;W$
PRINT LEFT$(W$, 1)
PRINT RIGHT$(W$, 1)
END
8. Display the sum of the digits of the entered number by the user
CLS
INPUT “enter any number”;N
LET S = 0
TOP:
LET L = N MOD 10
LET S = S + L
LET N = N \ 10
IF N > 0 THEN GOTO TOP
PRINT “the sum of the digits of the number is:”;S
END
9. Display a colorful "I LOVE YOU" message
CLS
SCREEN 13
LOCATE 14, 25
PRINT "Cool, Isn't It?"
LOCATE 22, 1
PRINT "-Truly Yours"
I:
PSET (10, 10)
PSET (70, 10)
PSET (10, 90)
PSET (70, 90)
icenter:
PSET (40, 10)
PSET (40, 90)
LINE.i:
LINE (10, 10)-(70, 10), 5'horizontal top
LINE (10, 90)-(70, 90), 5'horizontal bottom
LINE (40, 10)-(40, 90), 5'verticaL
L:
LINE (110, 10)-(110, 60), 6
LINE (110, 60)-(140, 60), 6
CIRCLE (170, 25), 20, 2
V:
LINE (200, 10)-(215, 60), 9
LINE (215, 60)-(230, 10), 9
E:
LINE (245, 10)-(275, 10), 11
LINE (245, 10)-(245, 60), 12
LINE (245, 35)-(265, 35), 12
LINE (245, 60)-(275, 60), 11
YOU:
LINE (80, 110)-(100, 140), 3
LINE (100, 140)-(120, 110), 3
LINE (100, 140)-(100, 180), 4
O:
LINE (150, 110)-(135, 140), 8
LINE (135, 140)-(150, 180), 8
LINE (150, 180)-(170, 140), 8
LINE (170, 140)-(150, 110), 8
U:
LINE (180, 120)-(180, 175), 14
LINE (180, 175)-(185, 180), 14
LINE (185, 180)-(220, 180), 14
LINE (220, 180)-(225, 175), 14
LINE (225, 175)-(225, 120), 14
END
10. Display user's details with music playing
CLS
DEFSTR A, H, N
DEFLNG C-E 'deflng c to e
INPUT "enter your name"; N
INPUT "enter your date of birth"; D
INPUT "enter your address"; A
INPUT "enter your age"; e
INPUT "enter your class"; C
INPUT "enter your hobby"; h
PLAY "a b"
PRINT
PRINT "You will be getting your details in a few seconds"
PLAY " a b c a a d e"
PRINT
PRINT
PRINT "Name: "; N
PRINT "Date of Birth :"; D
PRINT "Address: "; A
PRINT "Age :"; e
PRINT "Class :"; C
PRINT "Hobby :"; h
PRINT
PRINT "THANK YOU!"
PLAY "a b c a a a a b"
END
(You can copy each program to a Notepad File, and save that file with the extension of “.bas” and drag it to the application file of QBASIC. After that, the home screen of QBASIC will appear, and the double quotes (“”) maybe changed to ö. You can change them back to double quotes again. Then you can press F5 to run the program)
Those were 8 interesting QBASIC programs that you can try to make your friends and families amazed!
Do you use QBASIC?
- Run QBASIC on Android
Step-by-step procedure for running QBASIC with screenshots and QBASIC program outputs on Android.