google.com, pub-4617457846989927, DIRECT, f08c47fec0942fa0 Learn to enjoy every minute of your life.Only I can change my life.: Basic Programminng

Monday, August 25, 2014

Basic Programminng

The way we have different editions of a book ,a programming language also advances by each version .
BASIC also has many versions. John Kemeny and Thomas Kurtz originally developed it at Dartmouth College around the mid -1960 s.It soon became very popular because of its simplicity .Later ,others followed it and developed MS-BASIC,GWBASIC, BASICA and QBASIC.Initally ,Micrisoft Corporation developed MS-BASIC. Writing programs and getting results was a slow process  and to overcome this limitation ,Microsoft developed its faster version QBASIC .Full form of QBASIC is Quick Beginners All Purpose Symbolic Instruction Code.
It is simple and easily available.
QBASIC has an inbuilt editor .Editor helps in creating ,editing and storing text program files.We can create ,execute and debug a program without leaving QBASIC which speeds up our work.

How to start QBASIC :
It can be started as stated below :
1.By double clicking QBASIC icon on the desktop ,if it exists on the desktop .
2.Clicking on Start  -->Run and typing qbasic.exe along with its full path in the open text box thereafter confirming it by clicking on O.K.
Whichever way we start ,the welcome dialog box gets displayed first and which can be cleared by pressing the Esc key .Thereafter ,we can continue programming.

Rules of BASIC language :
1. Ther should be one satement per line .
2. If a statement does not fit in one line, we can continue it in the next line by inserting semicolon (;) at the end of the first line .
3. A statement should be completed in maximum two lines.
4. Each statement should be numbered .Normally we give number at the interval of 10 .First of all ,it is easy to write and secondly ,if need  arises ,we can insert a statement without changing the other line numbers.

Components of the BASIC language :
Our language comprises of sentences. A sentence is nothing but a combination of words ,and while combining these words ,we follow some rules and norms which we call grammar .Similarly ,any programming language has sentences like statements . These statements comprise of commands and expressions .We can combine commands and expressions to create a set of instructions (program ) which solves a particular program .Each programming language has its own rule for writing statements .Each statement should be written with proper order of command and expression ,which is termed as syntax .Each command has its own syntax.

Some BASIC commands:
1. REM
Syntax  :  <Line no>REM<text message>
Using the REM command ,we can write comments wherever required.

2. LET
Syntax  :  <Line no >LET<text message>
example:
LET A=20
LET SUM=A+B

3. INPUT
Syntax  : <Line no>INPUT<text message>
example:
INPUT "Enter name and age";Name$,AGE

4. PRINT
Syntax  : <Line no >PRINT<print item>separator<print item>......
To print more than 1 item ,we have to use separator like comma or a semicolon.
example :
50 PRINT X,Y,Z
60 PRINT "X=";X,"Y=";Y
70 PRINT
80 PRINT A;B;C

5. READ-DATA
Syntax : <line no>READ<variable 1,variable 2,....>
<line no>DATA<value 1,value 2,....>
example
40 READ name$,age
50 PRINT "Your name is";name$
60 PRINT "Your age is ";age
70 DATA "Vijay",40

6. GO TO
Syntax: <line no>GO TO<line no>
example :150 GO TO 50

7. IF...THEN...ELSE
Syntax: <line no>IF condition >THEN n

8. FOR.....NEXT:
Syntax: <line no> FOR<variable>=formvalue >TO <to value>STEP <value>
<statement to be repeated>


 <statement to be repeated>

<statement to be repeated>


NEXT <variable>

9.LOCATE
Syntax: <line no > LOCATE x,y

10 CLS
Syntax :CLS command clears the screen .Normally it is used to start the program .
Example: 10 CLS

11. END :This command is used to instruct the end of the program
example: 70 END



Program to find area of a circle :
10 CLS
20 REM Program to find Area of Circle.
30 INPUT "Enter Radius";R...
40 LET Area = 3.14 *R^2
50 PRINT "Area of Circle with radius "R;"is";Area
60 END

Program :FOR ...NEXT LOOP
10 CLS
20 REM Repeat Action
30 FOR I=1 TO 5
40 PRINT "I Love My India"
50 NEXT I
60 ENd
RUN  (For this Pres F5)
I Love My India
I Love My India
I Love My India
I Love My India
I Love My India

 Program to print the squares of first 50 odd numbers:
10 REM Program to print the squares of first 50 odd numbers
20 CLS
30 PRINT "Number","Square"
40 PRINT "-----------------"
50 FOR I=1 To 99 STEP 2
60 LET SQ=I^2
70 PRINT I,SQ
80 NEXT I
90 END

Output:
Number      Square
   1                  1
   3                  9
   5                  25
   7                  49
    .                  .
    .                  .
   97                 9409
   99                9801

Program to prepare a table of any number
5  CLS
10 REM Program to prepare table of any number
20 INPUT "Enter Any Number -",N
30 LET X=1
40 S=N*X
50 PRINT N;"X";X;"=";S
60 X=X+1
70 IF X<11 THEN GO TO 40 ELSE PRINT "OVER"
100 END
RUN ---------------(Press F5 key)
Enter Any Number -----------(Suppose we have entered  17)
We get output:
17x1=17
17x2=34
and so on
17x10=170
OVER

GRAPHICS IN BASIC
Program to draw a circle
10 CLS
20 REM Program to draw a circle
30 SCREEN 1
40 CIRCLE(70,85),25
50 END





शिव भोलेनाथ स्तुति

 जय शिवशंकर, जय गंगाधर, करुणा-कर करतार हरे,   जय कैलाशी, जय अविनाशी, सुखराशि, सुख-सार हरे जय शशि-शेखर, जय डमरू-धर जय-जय प्रेमागार हरे,   जय ...