Académique Documents
Professionnel Documents
Culture Documents
Getting Started
Ok, now open BASIC, (if you dont have it, you can get at www.gwbasic.webs.com for free). The BASIC window will look something like this:
Now type in the following code: PRINT 27+32 Theres nothing hard to understand here, first we used the PRINT command, and this is probably the most useful command in basic as it is the only way to produce output in BASIC. When you press enter, basic prints 59 and then prints ok which means that the program has ended. And thats it, were making programs in BASIC! Result: 59 Ok_ Now try using double commas, retype the program like this: PRINT 27+32 Result: 27+32 Now we see that if we use commas, instead of calculating the data, BASIC prints it as it is, So lets put this all together: PRINT 27+32=;27+32 Theres nothing particularly hard to understand, the only new thing is the semicolon ;, which is used to separate numeric data from string data, in the same program if we use comma , instead of semicolon, BASIC would have printed it in indents (tabs). Try experimenting with PRINT commands and commas and semicolons.
Let Statement
Ok, so this is a rather interesting statement as it lets you assign a value to a data place known as variable. Its rather easy, as we just have to give the variable name, = sign, and then the value, for example, type the following code: X=5 This assigns the value 5 to the variable X, Now in the same way, assign value 10 to variable Y: Y=10 We can also store different variables in one variable for example: Z=X+Y Now lets test it, type in the following code: X=5 Y=10 Z=X+Y PRINT Z The result should look something like this: 15 Ok_ We can also assign string data to variables, which are alphanumeric data, we just have to add $ sign in front of variable, and add double quotation around the phrase, for example:
X=10 Y$=The sum of 2 and 8 is Print Y$;X The result should be like this: The sum of 2 and 8 is 10 Ok_ (Note: you cannot combine different data types into one variable, e.g. z=y$+x)
Valid Name
NUM5 TOTPAY NETPAY BANDW
Now lets make our first program to calculate average of 3 numbers: 10 A=2 20 B=4 30 C=6 40 AVG= (A+B+C)/3 50 ? AVG 60 END Ok, now we see two new things, firs is the question mark ? which is actually a shortcut for PRINT command, which requires no explaining, second is the END command, this command tells the computer when to stop the program. Now type in RUN to start our first program, the result should look like this: