Custom Search
 
  

 
Predefine Functions

Some mathematical functions, for example, square root and tangent, are used so frequently that they have been incorporated into the BASIC language as predefine functions. You can use these to compute the same mathematical function with many different values. Rather than writing the coding required to do each calculation, you may use the "function" capability of the BASIC language. For example:

This will cause the computer to calculate the square root of 36 and assign that value to X. Table 2-4 shows a list of some of these predefine mathematical functions.

Table 2-4.Predefined Functions

FUNCTION 

ABS (X) 

ATN (X) 

COS (X) 

EXP (X) 

INT (X) 

LOG (X) 

RND (X) 

SGN (X) 

SIN (X) 

SQR (X) 

TAN (X)

DESCRIPTION

Absolute value of X

Arc tangent of X in radian measure

Cosine of X in radian measure

Natural exponential of X

The largest integer not greater than X

Natural logarithm of X (base e)

Generates random numbers between 0 and 1

Algebraic "sign" of X: -1 if X<0, 0 if X=0, and +1 if X>0

Sine of X in radian measure

Square root of X

Tangent of X in radian measure

FUNDAMENTAL CONCEPTS

Up to this point, we have been discussing the mechanics of the BASIC programming language. We will now discuss fundamental concepts and how you use these in your interaction with the computer in keying in and running your programs. This will include more about statement numbers, spacing within statements, keying statements into the computer, methods of correcting mistakes, how the computer responds when your program contains a syntax error, and the use of the REMARK statement.







Western Governors University
 


Privacy Statement - Copyright Information. - Contact Us

Integrated Publishing, Inc. - A (SDVOSB) Service Disabled Veteran Owned Small Business