QBasic Programming for Beginners – Introduction to Programming in the QBasic Programming Language

welcome back to the adventure this is
Adam and today we’re starting a new series on Microsoft basic the beginners
all-purpose symbolic construction code otherwise known as basic is a
programming language like spoken language there’s a vocabulary grammar as
we will explore an upcoming episodes the vocabulary consists of fewer than 200
words or keywords as will refer to them and the grammar will be referred to as
syntax to get started let’s open qbasic a first glance qbasic looks like the
edit program there are some similarities between the two qbasic does have some
word processor features however qbasic is far more than a text editor let’s
start our first program will need to begin with a line number the traditional
number to start with is 10 this isn’t so much of a problem today but in years
past editing a line number would require deleting an entire line of code so if
you needed to add something in between two lines of code it was easiest to
leave room between the line numbers for line ten will use CLS hey that looks
familiar clear screen yes like how we use at echo off in batch files this is a
good place to start when writing a program and basic next we’ll need the
program to do something so let’s add another line number notice that the word
print is capitalized for us after we press the Enter key print is a keyword
and Q basic checks the syntax for key words and can make some minor
Corrections for us the print statement is going to display the text in
quotation marks on the screen last we’ll add the line for end this will end the
program now let’s try running the program the words hello world are shown in the
upper left corner of the screen while short and simple this is a complete
program a line of code in basic is referred to as an instruction basic
understands two types of instructions those are statements and functions
statements and functions look similar but serve different purposes the
statement does what you tell it to do when the program is run the function
returns information that you can use in your program let’s take a closer look at
the syntax for the print statement similar to how a command has parameters
a statement has arguments the print statement has two arguments these are
the expression lists and either a comma or a semicolon the expression list is
what gets displayed on the screen in this case hello world you can also
display a number with no quote marks we run the program that’s going to
display the number 25 you can also enter an equation like 2+2 so if you run the
program we will get the result of two plus two equals four alternatively we
can use a function within the print statement such as date dollar sign and
we can add another line of code here to print time dollar sign and we could
actually further add another print statement in here with no arguments to
find so now if we run this program we get the
date and time this will display the current date and time when you run the
program as for the second argument the print statement understands you can use
a comma followed by another expression list item this works like pressing the
tab key or you can use a semicolon which displays the expression list item next
to each other and that will look like this when we run
the program so at the top we have the date followed by the time as if you were
to press the tab key in the second example we have the date and time all
run together and the print statement with no argument is just with putting
that blank line space in there right that completes our look at the print
statement until next video I’ll be down in the comments

Leave a Reply

Your email address will not be published. Required fields are marked *