Showing posts with label STATEMENT. Show all posts
Showing posts with label STATEMENT. Show all posts

Tuesday, 14 February 2012

0 GW-BASIC [INPUT STATEMENT]

INPUT STATEMENT is use when  you don't know the value , which should be input, like you have to make a BIO-DATA for 32 Students you  don't make different Program, you can just make a program with INPUT statement ,
FOR EXAMPLE
10 CLS
20 INPUT "ENTER YOUR NAME";N$
30 INPUT "ENTER YOUR FATHER NAME ";F$
40 INPUT "ENTER YOUR CLASS";C$
50 INPUT "ENTER YOUR AGE";A
60 CLS
70 PRINT "NAME:";N$
80 PRINT "FATHER NAME:";F$
90 PRINT "CLASS:";C$
100 PRINT  "AGE";A
110 END
When You run this , The Screen show you
ENTER YOUR NAME? SHAHZAIBBAIG
ENTER YOUR FATHER NAME? NAIR
ENTER YOUR CLASS? 9TH
ENTER YOUR AGE? 15
When You Enter the Name ,Father name, class and age
the result will be
NAME:SHAHZAIBBAIG
FATHER NAME:NASIR
CLASS:9TH
AGE :15
every time you run , this message will appear every time, if you don't use PRINT statement the result will not shown, so PRINT is an important , always remember that String[Alphanumeric] DATA will written with Quotation mark and Numeric data without Quotation Mark, 

3 GW-BASIC [FOR-NEXT STATEMENT]

In GW-BASIC FOR-NEXT is use for looping , you can print any number more than 1 time easily .
how to write FOR-NEXT
10 FOR A=1 TO 10
20 PRINT SHAHZAIBBAIG
30 NEXT A
Where A is a variable , 1 TO 10 this will PRINT SHAHZAIBBAIG 10 times, you can PRINT more than ten time, its is useful and short STATEMENT of GW-BASIC , NEXT Command is must if u donot write at the end the loop will not work and give you syntax error.

Some Examples
10 FOR A = 3 TO 28 STEP 5
20 PRINT A
30 NEXT A
Where STEP 5 will PRINT Like this 3 then 8 then 13 then 18 ....

You Can also do this
10 FOR A= 28 TO 3 STEP -5
20 PRINT A
30 NEXT A
This will minus 5 from 28 , when 3 comes program will stop


Monday, 13 February 2012

0 GW-BASIC [PRINT STATEMENT]

PRINT means to print any data consist of numeric and alphabets .
In GW-BASIC , we use print instead of echo it is simple and easy.
PRINT "Your Name"
PRINT 23-23
PRINT 1

QUOTATION marks are use in string [alphanumeric] data
You can write Numeric data with out QUOTATION mark ,
Share

Widgets

 
Design by Shahzaib Baig