QBASIC code/Editor Screen
(Press key [F5] to make the program RUN/execute...)
====
(Pressing any key returns you straight back to the Editor screen; where you can either chose to further Edit/Re-Run/or else, Save your program.)
Here is another example.
CLS
COLOR 15, 4, 14
PRINT "Press any key to continue"
DO WHILE INKEY$ = ""
LOOP
FOR c = 1 TO 20
COLOR c, 0
PRINT "Replace this with the name you want to display"
NEXT c
COLOR 15, 0
END
EXAMPLE 1 The QBASIC program will, automatically, *capitalize* any reserved 'keyword' which it finds once you've already gone and typed in a line of code; and, then, at the end of that code line, do finally press the [RETURN/ENTER] key...to confirm what you've just gone and typed in. A keyword might be say the PRINT command statement...so, if I were to type inside of the QBASIC editor the following line of code... print 1+1 ...then, the moment I press the [RETURN/ENTER] key when I get to the end of that line...the QBASIC interpreter program will, automatically, change the 'lower case' word: print...to become all UPPERCASE, instead; QBASIC Editor will display the previous line of code I typed in as being... PRINT 1+1 ...thus, I am able to tell immediately that PRINT is a special reserved 'keyword'/or, command statement which the QBASIC program, quite clearly, recognizes and understands. This also helps me the programmer to know if I actually typed in that 'keyword' either correctly/or, incorrectly; if wrong...and, the program did NOT automatically capitalize it...; then, I know I must have either accidentally 'misspelled' the keyword/or, must otherwise have done something to go get it wrong...?! EXAMPLE 2 If I were to type in to the QBASIC Editor program the following line of code using all 'lower case' letters... x=10: if x=10 then print "ten" else print "NOT ten" ...and, then, when I've reached the end of that line of code, press [RETURN/ENTER] key to confirm my code entry; the QBASIC interpreter program will, automatically, respond by capitalizing any reseved 'keywords' that it finds; then, QBASIC Editor displays the line of code I typed in as being... x=10 : IF x=10 THEN PRINT "ten" ELSE PRINT "NOT ten" Looking at this newly capitalized line...it tells me that... IF/THEN/ELSE/PRINT...are all QBASIC reserved 'keywords'. NOTE: Whatever is a string a text that is written in between double quote marks: ("") will be totally unaffected by such capitalizing; instead, text strings will be printed out, quite literally, 'as is'. FINAL NOTE There are far too many QBASIC 'keywords' for me to go and list here; possibly, a couple hundred...! QBASIC has many 'keywords' that it uses; if you wish to see what ALL of these keywords are; then, from inside of the QBASIC Editor program itself...do a combination key press of: [SHIFT] + [F1]...and, there you will see the Help file...that shows each 'keyword' you can use to write QBASIC programs with; as well as, offering a clear explanation/it shows 'example codes' demonstrating exactly how each of these 'keywords' should be used; just do 'copy & paste'/then, RUN the program to follow these examples along.
Cls print the multiples tables of 1 to 5 for x=1 to 5 for y=1 to 10 print x;"*";y;"=";x*y next y print print next x end
Difference between QBASIC and GWBASIC?
QBasic is a programming language that was developed by Microsoft in the early 1990s. It is an interpreted language, which means that the code written in QBasic is not compiled into machine language before it is executed. Instead, it is interpreted by a program called a "compiler," which reads the code and executes it on the fly. QBasic is a simple, beginner-friendly language that is well-suited for learning the basics of programming. It is based on the older programming language BASIC (Beginners All-purpose Symbolic Instruction Code). It is not actively developed anymore, but still can be used for educational purposes.
The advantage of qbasic is that it is easy to learn, to start out,then one can move on to more complex, or advanced languages.
you do this 10 print "0112358132134" use the whole of the thing
END '...END of program/halt program code execution. *NOTE*: There should be only 'one' END statement written inside of a QBASIC program. I have seen example code where they use multiple END statements; this is wrong!
To stop a program from running in QBASIC, you can press "Ctrl" + "Break" on your keyboard. This interrupts the program execution and returns you to the QBASIC command prompt. Alternatively, you can close the QBASIC window to terminate the program. If you want to exit gracefully, you can also use the END statement in your code to stop execution at a specific point.
(1) Immediate mode In this mode, QBASIC performs the command/instruction that we type in immediately after we press the enter key. (2) Program mode In this mode, the instructions/commands we type in are not performed as we type them in, but are first stored in the computer memory as a program. This program can be executed later, at a high speed.
Write a program that calculates the area of a triangle in QBASIC
If you are using windows, MSDOS shell is integrated by default..
a triangle then a square :)
H. Tornsdorf has written: 'Windows 3.1 - Trucos y Consejos' 'QBasic for beginners' -- subject(s): QBasic (Computer program language)
In QBasic, the CLS statement stands for "Clear Screen." It is used to clear the current screen of any text or graphics, providing a clean slate for subsequent output. When CLS is executed, all visible content is removed, allowing programmers to refresh the display during a program's execution. This is particularly useful for improving readability and organizing output in console applications.
The QBASIC program actually comes in 2 different flavors... A> QBASIC interpreter program: QBASIC Version 1.1 B> QBASIC compiler program: QBASIC 4.5/or, QB64/or, -etc. ...so, the answer is that this programming language comes in both forms: 'interpreter/compiler' versions; and, you have to select which of these you would prefer to download and use. *NOTE*: The compiler version of the language tends to be much larger; whereas, the interpreter version of the language tends to be small/very compact, indeed; thus, the interpreter tends to take up far less disk space. Many people start off their programming career by using QBASIC version 1.1 'interpreter' program; in order to learn 'how to' program. The interpreter version of the program can only create plain text (.bas) files; the which code CANNOT be shared with others; (not unless the persons who you are sharing this type of code with do already have a copy of the QBASIC interpreter program installed on their own computer). Then, later on, down the line...when they have become fully capable programmers themselves; they go and download a QBASIC 'compiler' program version, instead; which will allow them to go and create stand alone (.exe) program files that they can share with anybody. This is because (.exe) program files can RUN/execute entirely independently of the QBASIC program itself.
QBASIC GRAPHICS There any many different things you can draw in QBASIC; ranging from... -dots -lines -rectangles -circles -shapes empty/or, filled in(painted) -you can even do LOGO style programming to draw graphics with; by joining up connected lines -animations are possible, too ==== QBASIC BUILT-IN HELP FILE + CODE EXAMPLES In order to view the QBASIC built-in Help file...; first, load the QBASIC program itself...; and, then, do a combination key press of: [SHIFT] + [F1] Use the built-in QBASIC Help file to learn more about how to use these 'graphic related' commands, and, more...! The QBASIC Help file also contains plenty of 'example codes'; which you can just use 'copy & paste'; then, RUN...to see what the output effect will be...???
Yes I can. I did it in QBasic about 15 years ago.