Liberty and Accessibility

Wednesday, September 12, 2007

variables, input, and output

In order to get input from the user, you have to use variables.
Basically, a variable stores information in RAM. A few types of
variables that can be used in FreeBASIC are strings, integers, and
doubles. If you want to store things such as people's names, you would
use a string. If you want to store numbers or do math, you would use
an integer or a double. An integer is used for whole numbers such as
1, 2 or 3. A double can be used if you want to store decimal numbers.
In order to use a variable in FreeBASIC, it has to be declared using
the dim statement. For example, if you want to use a string, you would
use the following code:
dim presidential_candidate as string

To get input from the user, you can use the input command. The
following code gives an example of this:
dim presidential_candidate as string
print "Who is your favorite US presidential candidate?"
input presidential_candidate
print "You picked ",presidential_candidate,"."
'end of code'
If you save, compile and run that program, you'll see that it asks the
user to pick a presidential candidate. Then it prints who the user
picked. In the next installment of the Ron Paul programming tutorial,
I will discuss how to get the computer to make decisions about the
user's input.

Email services provided by the System Access Mobile Network. Visit to learn more about accessibility anywhere.


Post a Comment

<< Home

Read the Bills Act Coalition Add to Technorati Favorites