qb45advr.hlp (Topic list)
SQR Function Programming Example
  QuickSCREEN      Details     Example      Contents      Index
──────────────────────────────────────────────────────────────────────────────
SQR Function Programming Example
 
The following program plots the graphs of
y = √-x for -9 <= x <  0, and
y = √x  for  0 <= x <= 9:
 
'*********************************************************************
' Example program for SQR function.
'*********************************************************************
SCREEN 1 : COLOR 1           'Low-resolution color graphics mode.
WINDOW (-9,-.25)-(9,3.25)    'Convert screen to Cartesian coordinates.
LINE (-9,0)-(9,0)            'Draw X-axis.
LINE (0,-.25)-(0,3.25)       'Draw Y-axis.
FOR X = -9 TO 9
    LINE(X,.04)-(X,-.04)     'Put tick marks on X-axis.
NEXT
FOR Y = .25 TO 3.25 STEP .25
    LINE (-.08,Y)-(.12,Y)    'Put tick marks on Y-axis.
NEXT
PSET (-9,3)                  'Plot the first point of function.
FOR X = -9 TO 9 STEP .25
    Y = SQR(ABS(X))          'SQR argument cannot be negative.
    LINE -(X,Y),2            'Draw a line to the next point.
NEXT