0% found this document useful (0 votes)
2 views23 pages

2986

The document appears to contain a variety of programming concepts, including data types, variables, and operators, likely related to the BASIC programming language. It includes examples of syntax and reserved words, as well as explanations of different data types such as integers and strings. The content is fragmented and includes various symbols and characters, suggesting it may be a corrupted or improperly formatted file.

Uploaded by

ahmadabdlkadrss
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views23 pages

2986

The document appears to contain a variety of programming concepts, including data types, variables, and operators, likely related to the BASIC programming language. It includes examples of syntax and reserved words, as well as explanations of different data types such as integers and strings. The content is fragmented and includes various symbols and characters, suggesting it may be a corrupted or improperly formatted file.

Uploaded by

ahmadabdlkadrss
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

    

   
    

   

 ! "#$  !.:  

2007
@ áîyŠÛa@廊Ûa@ a@á i
: 
               
$  !      % & '( ) #     !  "#
 /&  0 1  ., -& –    * '( 
 !    – 3  45     "#  2&
. 0 1   7  &8 4 6/  
:   
 "2  1 ) HLL "#  9  1 %& 0 1
"; / 7" : BASIC "   $  2&
/ 5( % .Beginner's All-Purposes Symbolic Instruction Code
-&8 "2   1 2 7 4) & < = >  "7
1   7  :: =  # < =? -& 1 2 &"
.COBOL   $
& 5 A     &&#    1 %@ 0 1
. && 7 4  7  7  &&# "# 04  & "
:BASIC Alphabet      
: A      &&#  0 1 A@
z B a  (/  A )Z B A  "; &  A  .1
. (/ 1: A )
. 9 B 0  -E  .2
.N ...@!&^%$ =  +  : !7    .3

: Reserved words  !  "!# 


 (main words)   "    7 4 " )
1  A 7 $ E " ) (key words) 5 "
 7 2&  8 $ 2 && < 1" 2&  0
0  2 & 8  04  1 2&  8  3  2 7
:" O4)    "#  B
@ bjÇ@廊Ûa@†jÇ@Z…a†Çg@–@ïãbrÛa@õŒ¦a@–@ò©Ûa@pbîbc

if , else ,end if , case , for, next, goto , , do , end

: Identifier "$ ! 
 1 :  5" 3  :7 7    0" )
.  5: ,  &,  
:2  (  7"
 ( !# -&   -E   & A  "# 9   .1
. (under score) (_) 
A  -& Q &   A 7       .2
. /   / 1:
(_) &# :      A 7    , .3
7 4 R    ,  A 7"    R5 .4
&
:  
REAL , X , area10 , Y15 , tax_rate, Sum_4 , total_value ,
     
&address , 5th , last name , order-no , char , "a"

:constant % & 


! " #$%& '($) *+ ,&"- )% ,.) " /0&" 1 '23)  %&"&
/+"<& 6& ;- * )%& 6& * *78& 9) : 4)1 5) *6
: =)6 const
Const ident=value
)%& @& value " %& ?& 9& ident >
const pi = 3.14 7 A 
:Variables "'! 
#   / 4    E    #  1
  3  45   S %  TE 1 > 1 4) 3 
. 1 E %&   - &&  U  1

:Data Types "(  ) (*


:B 0 1   U  -$

3
@ bjÇ@廊Ûa@†jÇ@Z…a†Çg@–@ïãbrÛa@õŒ¦a@–@ò©Ûa@pbîbc

: #  -R Numerical data type &&7  6


: #  -R  (7 ":5   -E  ) : : &&#  6
./ 4   2 4@ integer : &&#  .1
./ 4   4 4@ Long /  : &&#  .2
(  (7 ":5) floating point 7 $ 4 $$ &&#  6
: #  R -R
. single /& 5 E& 4 $$ &&#  .1
.double  & E& 4 $$ &&#  .2
. string ( :)   6
$ !# RV   &&7  7  0 1  # / :
.&&7  7  24    7 E
:!
W 
E 1 NO=100
.% 1 $name=”Ahmed”
/ 4 - A 7 "  U 
2byte(16 bit) integer %&# Q:
: &&#
4 byte(32 bit) long   Q:
4 byte(32 bit) single /& 5 E&
$$ &&#
8 byte(64 bit) double  & E&
- string - 
: "$ !   "'!  +, -.,/ 01
1: Dim /  " -& ( 1)  7 # !#; -
: 7
Dim var-name AS data_type
: 
. 1 - :Var_name
. U  :Data type
. /  " : Dim,as

4
@ bjÇ@廊Ûa@†jÇ@Z…a†Çg@–@ïãbrÛa@õŒ¦a@–@ò©Ûa@pbîbc

: " 
Dim no as integer
Dim phone as long
Dim x as single
Dim y as float
: /& / #  1   # !#; 
Dim a,b,c,d as integer
:23'!  45  $ !  ) (
type /  " -& &&  U  && - $  -&" 
:
TYPE Tname
Var1 as data type
Var2 as data type
End Type
:Operators "67! 
:Arithmetical Operators   
:  "7  B    X )
8 ! 67! 
> "# +
Y  "# -
, R "# *
$ "# /
$ E mod
: $ \
[  ^

5
@ bjÇ@廊Ûa@†jÇ@Z…a†Çg@–@ïãbrÛa@õŒ¦a@–@ò©Ûa@pbîbc

:    


(  X /&# "# % ) /&$7  "#  B &#
: &  "7    , 45 - $ -  
8 ! 67! 
[ E  ()
[  ^
, R "# *
$ "# /
$ E mod
: $ \
> "# +
Y  "# -
\: =

&&7 &7 \ X  5 mod 3=2 !


W  $ E &7 mod X
5/3=1 !
W  $ "#  Q:

:Logical Operators   


:)  7  $   $  X

8 ! 67! 
and X and
OR X or
not X not

6
@ bjÇ@廊Ûa@†jÇ@Z…a†Çg@–@ïãbrÛa@õŒ¦a@–@ò©Ûa@pbîbc

:Relational Operators   


3 W &      E -E  $  $!7  X 
. (1  0)True – false @  Q: $!7  $ 7
8 ! 67! 
 E <
  >
%    E <=
%     >=
%  8 <>
%  =

:Expressions  ' 


7  1"    2        7 
:  7  #  0) 7   X  #  "# % 
:Arithmetical Expression   
W& x+y*(z-3)+x/2 !
W    X "# %   7 )
.E -E  7 3
: Logical Expression   6
x<=10 !
W  $  X "# %   7 )
 @  Q: 7 O4) 3     W & ,(x>5)&&(y==3)
. (1,0)] 0 1 
: statements " 
%4 (source program) &: 3 "   "7  7 
  %4 (object program) A&2 3  B T"  -  - $
.3  , 2"     @"

7
@ bjÇ@廊Ûa@†jÇ@Z…a†Çg@–@ïãbrÛa@õŒ¦a@–@ò©Ûa@pbîbc

&; , " )  2 0 1      &&7 0)
3  45   -  $"7 RB    #  
:  7 O4)  &&# " 
:Comments " '  •
 3  " QR  $   #  -& $"7
$"7 -  ) .  3  - 2   " # ["
'"7 , dim /  " -& '"7   2  - $ 8
.("7 ":5) ’   -&  )&2
:!
W 
Dim here you can add your comment

’here you can add your comment

: input & out put statements 9:/  ;:</ ", •


:   !
 3  B   E  -$ &B #    7 )
:  7 0 1 -R
:read-data "  1
- 8 3  & /       / 7 O4) -&
1:  3  45   (key board)  &; /&  2&B
:/ 7 O42 7

Read list of var


…..
…..
…..
Data list of values
 1 E :List of var
.-$ E : List of values

8
@ bjÇ@廊Ûa@†jÇ@Z…a†Çg@–@ïãbrÛa@õŒ¦a@–@ò©Ûa@pbîbc

.5 " :Read, data


E    W  (  data "# read / # -&$  W  ( [
. -$ $    1
: 
Read x,y,z
…..
Data 10,5,3
:Input "  2
&B /&  3  45    &B  / 7 O4) 0
- $   3  -&  #5 Q   Q5    
 &V -& - $   # -&  3 
:/ 7 O42 -7 ( .  "
Input”message”,list of var,
  ) -& 3   #5  message 
/&#  & 1   &E   1 E list of var  .24 
.  1
: 
Input “enter three numbers”,x,y,z
:Output Statements #   
 _ ; & "#  "7 < # #   _ `  #
:_ ;  #   7 ((
: PRINT / # 61
>  2  (( "#   # / 7 O4) -&
: 7 1:  ""  E -E
PRINT “MESSAGE “,VAR OR EXP
. :  MESSAGE 7 :EXP  1 VAR
: " 
PRINT “THE OUTPUT”
PRINT “X=”,X;
9
@ bjÇ@廊Ûa@†jÇ@Z…a†Çg@–@ïãbrÛa@õŒ¦a@–@ò©Ûa@pbîbc

PRINT”SUM=”,A+B+C
PRINT X,Y,Z
PRINT A*B+C/3
\ : # 2 PRINT / #  QR $ "   
 7 3   1 -E  "" \: !#  27R  (
.,  %@ '    "   $  
:Lprint / # 62
< 7 (( # 8
W & 7 "#   # / 7 O4) -&
.Print / #   W  -&
.assignment statements =>3'  ", •
$    E -E \: &V \:  # - $
.(=) \: X 27 -&  1
$ value 1 var1   var1=value: 7 1:
&; "#  LET " -&   <7   1 B /&
. LET VAR=VALUE !
W 
: " 
Radius=15;
Let x=105
$   7 3 ,  W R &; / # -&
LET SUM=A+B+C  SUM=A+B+C !
W 
:(162)  " " 
: 0 1" 3  ,
:  7 3 # .1
1- A+B*C/2-5*B
2- (A<B)AND(C<5)OR(B=10)
3- A^2+B*C
A=3,6=10,C=64
:( ) / 7 # .2
WELCOME TO BASIC PROGRAMMING

10
@ bjÇ@廊Ûa@†jÇ@Z…a†Çg@–@ïãbrÛa@õŒ¦a@–@ò©Ûa@pbîbc

2#  # &&#3 / $. .3


2  , &&#B 5 / $ .4
AREA= / &  , .5
:
:Þëþa@wßbãÛa
Cls
A=3
B=10
C=6
Exp1=A+B*C/2-5*B
Exp2=(A<B) and(c<5)Or(B=0)
Exp3=A^2+2*B*C
Print “Exp1 =”,Exp1
Print “Exp2 =”,Exp2
Print “Exp3 =”,Exp3
End.
@ Z@pbuŠ‚½a

Exp1 = -17
Exp2 = 0
Exp3 = 129

@ NZïãbrÛa@wßbãÛa
Print “Welcome To Basic Programming"
End.
pbuŠ‚½a

Welcome To Basic Programming

Z@sÛbrÛa@wßbãÛa
Input “Enter Three Numbers”,A,B,C

11
@ bjÇ@廊Ûa@†jÇ@Z…a†Çg@–@ïãbrÛa@õŒ¦a@–@ò©Ûa@pbîbc

Sum=A+B+C
Print “the summation = “,sum
End
pbuŠ‚½a
@
Enter Three Numbers 1,2,3
the summation = 6 @
@
@
@ ZÉiaŠÛa@wßbãÛa
Cls
Input “please enter 5 numbers” , A,B,C,D,E
Sum=A+B+C+D+E
AV=sum/5
Print “the Average =”,AV
End
pbuŠ‚½a

Please Enter 5 Numbers 1,2,3,4,5


the Average = 3

Z,ßb¨a@wßbãÛa
const pi=3.14
input “enter the Radius “ , R
area = pi*R^2
print “the area =” , area
end
read .. data / # -&  3   /&#B

Cls
Read A,B,C
Exp1=A+B*C12-5*B
Exp2=(A<B) and(c<5)Or(B=0)
12
@ bjÇ@廊Ûa@†jÇ@Z…a†Çg@–@ïãbrÛa@õŒ¦a@–@ò©Ûa@pbîbc

Exp3=A^2+2*B*C
Print “Exp1 =”,Exp1
Print “Exp2 =”,Exp2
Print “Exp3 =”,Exp3
Data 3,10,6
End.

:Control Statements @#'  ", •


 5  B "#   "" / : 45 & 3  % 45 &#
   /&&  (  "7 45   3  45   -"
E B 0 1  -  # -$   7 "7 45
: 
.branching statement (U 5)  (  # 
.loop statements    # 
:)0'  ", : AB*
:IF "  
&&  ( W$  # 45 ! -& -  # 2( )
: / 7" 7 1:
If Condition THEN
STATEMENT
Else
Statements
END IF
.@  , :  $ 7 :condition
.)45 -  #  / # :Statements
.@ $ 7 3  4B 2  "7 45 :Else
condition  ( 7" S -   if..then / # 45 &#
3  4B   / ( 45 2   7  (1) , : T  4V
 . )45 - else / 7   7 V (0)@ $ 7
'$ 4B )45 - /&&  # 0)  4 else / # # 18
. ($ 7) ( '$ -&#   9   # &  8   (

13
@ bjÇ@廊Ûa@†jÇ@Z…a†Çg@–@ïãbrÛa@õŒ¦a@–@ò©Ûa@pbîbc

!
W 
x=5
if x<7 then
print “less than seven”
else
print” greater than or equal 7”
end if
$ 7 3  " less than seven"  / 7 > $ / 5(
-  print / #  (x>7)] $ 7 & 4B  .(1 Q:)
.(0 @) Q: 7 3  )45
:select case "  
 $     if / 7  )45   /&# -&"   / 7 O4)
:/&&#  (  /&&#     select
 $%
Select case(var)
Case val1:statement1
Case val2:statement2
Case val3:statement3
Case else:stat_def;
Select end
-& O  %4  (     / # (select case)  
case  #  select case / 7 #   $ (var) 1
$" W$ )45 -  / 7 && case val1,2,3 5" -$ / 
 2"1( -  R 8 / 7 2 stst_def  .var # / 
. case -E  %
b  > /  $ ' -&# 
:!
W 

Select case (5)


Case 1: print” one”
Case 2:print “two”
Case 5:print”five”
Case else :print”none”
Select end
. case 5 / # E > 5 /  $ '" "five" > $  7

14
@ bjÇ@廊Ûa@†jÇ@Z…a†Çg@–@ïãbrÛa@õŒ¦a@–@ò©Ûa@pbîbc

:loop statement #'  ", : A(6


!     /&#    / #   B _ &E 3  <7 
[ 4)  _ B / #  B _ V  "welcome" / # #
. / 4         E 4@
 / #   "# &#  E        #
:  7 O4)  . / 1:    -&   /&#  #
for .. next " 
  # /&# 45   "# &#    # %& for / #
: / 7 O42 7 1:
For count= init_val to max_val step val
Ststemants
Next count
: 
. /  " :For,to ,step,next
.&&7   & &&# , (integer ,long) ,  E 1 : Count
.count &&7"   $ Init_val
. & )&# AE   2 $ :Max_val
.1 ) 7 -   , - 4B &&7  /& &$ :Step
.)   -   7 :Statement
: /   welcome / # # !
W 
For i= 1 to 100
Print “welcome”
Next i
next / 7  step /   -&7 1 /& &7 I &&7 1 S8
S7 $"   &&7 E Q: - 4B /&& / & c(  / & 2
.max_val
while wend "  
 ( W$ "#   -$ 2     #  R while / #
:/ 7 O42 7 1:  /&&

15
@ bjÇ@廊Ûa@†jÇ@Z…a†Çg@–@ïãbrÛa@õŒ¦a@–@ò©Ûa@pbîbc

while condition
statement
wend
: 
2   &&     (   &&  /  " :While wend
.)45 -   7
)45 -   7 Statements
: while -& /  100 welcome / # # !
W 
i=0
While i<100
Print “welcome”
i=i+1
wend
T /& &$ && (i=0) T & E >R , I &&7 S8
. (i=i+1)

do while "  


:7 1:  2# A" while wend / #   T(
Do while condition
Statements
loop
'   [5 do RB loop , wend & $
:do while -&
i=0
do While i<100
Print “welcome”
i=i+1
loop

:do until "  


4B T  while wend do while # do until / # A"
    # AE  do until V true $ 7 E 
.9    7 

16
@ bjÇ@廊Ûa@†jÇ@Z…a†Çg@–@ïãbrÛa@õŒ¦a@–@ò©Ûa@pbîbc

: 7 1:
Do until condition
Statements
loop
 ( '$  7 ) AE   ( && : do until condition
.  loop  (condition
:do until -& '  
i=0
do until i=100
Print “welcome”
i=i+1
loop
.i=100 Q: &# AE  % i=100 B 1  ( S8
(2D2)  & *
.  -E  # E / $ 3  , 61
"; 1" -E  # 6 6 1 E E 8 3  , 62
. select case -&
: # 0 1" 3  , 63
20 B 1  &&#  61
2061  & 5 &&#  62
: 23'5
:for D1
While wend D2
Do while D3
Do until D4

17
@ bjÇ@廊Ûa@†jÇ@Z…a†Çg@–@ïãbrÛa@õŒ¦a@–@ò©Ûa@pbîbc

:;  
; F ( 
Cls
Input”enter two numbers”,x,y
If x>y then
Print X ,“is greater then”, Y
Else
Print X ,“is greater then”, Y
End if
End
pbuŠ‚½a
Enter two numbers 5,8
8 is greater than 5

:8(&  F ( 
Cls
Input” enter your choice”,ch
Select case(ch)
Case 1:print” you choose one”
Case 2:print” you choose two”
Case 3:print” you choose three”
Case 4:print” you choose four”
Case 5:print” you choose five”
Case 6:print” you choose six”
Case else :print “out of choices”
Select end
pbuŠ‚½a
enter your choice 4
you choose four

:F  
100D 1 + <, ,G .*
for 23'5 D1
cls
for i= 1 to 20
print i
next i

18
@ bjÇ@廊Ûa@†jÇ@Z…a†Çg@–@ïãbrÛa@õŒ¦a@–@ò©Ûa@pbîbc

end
while wend 23'5 D2
count=1
while count<=20
print count
count=count+1
wend
end
do while 23'5 D3
cls
count=1
do while count<=20
print count
count=count+1
loop
end
do until 23'5 D4
count=1
do until count>20
print count
count=count+1
loop
end
pbuŠ‚½a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

19
@ bjÇ@廊Ûa@†jÇ@Z…a†Çg@–@ïãbrÛa@õŒ¦a@–@ò©Ûa@pbîbc

100D 1 + <0  <, ,G .H


for 23'5 D5
cls
for i= 1 to 20 step 2
print i
next i
end
while wend 23'5 D6
cls
count=1
while count<=20
print count
count=count+2
wend
end

do while 23'5 D7
cls
count=1
do while count<=20
print count
count=count+2
loop
end

do until 23'5 D8
cls
count=1
do until count>20
print count
count=count+2
loop
end

20
@ bjÇ@廊Ûa@†jÇ@Z…a†Çg@–@ïãbrÛa@õŒ¦a@–@ò©Ûa@pbîbc

@ pbuŠ‚½a
1
3
5
7
9
11
13
15

functions ; 
/) #  3  #  )  &  &&7 0 1  4
: 0 1   &  ( 7    -E , 3  2&

;& 0I    @5


Abs(-5) = 5 -E  $" $ , Abs()
Sqr(9) = 3 7   , Sqr()
Sin(3.14)= 0 &    , , Sin()
Log(1) = 0 &&7 - = " , Log()
Len(“ali”) = 3 ""  , Len()

( [ E     & –  ) E 4@ $  &  & 


. E > 
   "
# A"  T &:B   0 1  &:B  &&7 0)
:  &:; O4)  * &:;
• BASIC
• Quick basic
• GW basic
• Basica

21
@ bjÇ@廊Ûa@†jÇ@Z…a†Çg@–@ïãbrÛa@õŒ¦a@–@ò©Ûa@pbîbc

:Quick basic 


9     "# 2 ' 5   &&7 >  0  >
"#  5" S5 (B "#   "7  ,  - E "# T 
 (  45 'E& Q: "# &8    
:quick basic >  0  QR 

* + ‫ ا ) ا‬, 

(  ‫ن    ة ا  ) ا‬

"‫  ) ا(ﺱ‬+alt ‫" ا  ر    ب‬#‫ا‬$%

Q$   "#  Q5   Q5 -& 5   &
:3  45  
 ; A&2
new   -  file $ && A" (B
save   -  file $ A" S5

22
@ bjÇ@廊Ûa@†jÇ@Z…a†Çg@–@ïãbrÛa@õŒ¦a@–@ò©Ûa@pbîbc

open   -  file $ &   A" Q


: !7 -E  A   Q5 -&   / 5( 
shift+F5 Q5  start   run $ 3  1(
F1 Y5 "# 1R  help $ /&# ,"

: JK0!  L JK0 MNI


:  Q5   <7 _ &E   "#  

5S  Y5
- $ ( alt
(small – capital) A    & A  % + shift
  (X $ home
 d (X $ End
"#  (X $ "# -2
5  (X $ 5 -2
" A  (X $  -2
"#  "# -2
 2  Q delete
( 2  Q  Back space
(   7  '!=B ) , 2 esc
&&  Enter
3  1( Shift+f5

@
@
@ a@†à¡@ïãbrÛa@õŒ¦a@óènãa
@ 3bväÛa@ë@ÖìÐnÛa@âaë†i@áØÛ@ïmbîäßc

23

You might also like