Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
SQR Function Programming Example
◄Example► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
'The following program uses the SQR function to plot the graph of
'y = sqr(abs(x)) for -9 <= x <= 9.
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 X
FOR Y = .25 TO 3.25 STEP .25
LINE (-.08,Y)-(.12,Y) 'Put tick marks on Y-axis.
NEXT Y
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 X