|
QBasic provides several functions to do mathematical calculations. A few of them are discussed here. SQR Use SQR to find the "square root" of a number.
PRINT SQR(4) PRINT SQR(9) PRINT SQR(16) PRINT SQR(25)
2 3 4 5 ABS ABS returns the absolute value of a number. In other words, ABS converts a negative number to a positive number (if you pass a positive number, ABS does nothing).
PRINT ABS(-12)
12 COS, SIN, TAN, and ATN You can do the following trigonometric functions in QBasic:
SIN (Sine) TAN (Tangent) ATN (Arctangent, inverse of TAN)
PRINT COS(PI / 4) PRINT SIN(PI / 3) PRINT TAN(-PI / 2) PRINT ATN(TAN(-PI / 2))
.8660254 6137956 1.570796 (Same as PI / 2) Feel free to distribute this tutorial, upload it to your website, link to it from your site, etc. http://www.geocities.com/progsharehouse/qbtutor Mirror: http://development.freeservers.com/qbtutor |