ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

QBASIC Programs

Updated on January 28, 2013
The starting screen of QBASIC
The starting screen of QBASIC


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?

See results
working

This website uses cookies

As a user in the EEA, your approval is needed on a few things. To provide a better website experience, hubpages.com uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at: https://corp.maven.io/privacy-policy

Show Details
Necessary
HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
LoginThis is necessary to sign in to the HubPages Service.
Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
AkismetThis is used to detect comment spam. (Privacy Policy)
HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the googleapis.com or gstatic.com domains, for performance and efficiency reasons. (Privacy Policy)
Features
Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
MavenThis supports the Maven widget and search functionality. (Privacy Policy)
Marketing
Google AdSenseThis is an ad network. (Privacy Policy)
Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
Index ExchangeThis is an ad network. (Privacy Policy)
SovrnThis is an ad network. (Privacy Policy)
Facebook AdsThis is an ad network. (Privacy Policy)
Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
AppNexusThis is an ad network. (Privacy Policy)
OpenxThis is an ad network. (Privacy Policy)
Rubicon ProjectThis is an ad network. (Privacy Policy)
TripleLiftThis is an ad network. (Privacy Policy)
Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
Statistics
Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)
ClickscoThis is a data management platform studying reader behavior (Privacy Policy)