BASIC has a number of built-in functions that greatly extend its capability. These functions perform such varied task as taking the square root of a number, counting the number of characters in a string, and capitalizing letters. Functions associate with one or more values, called input, a single value called output.

## NUMERIC FUNCTIONS: SQR, INT

SQR calculates the square root of a number. The function INT finds the greatest integer less than or equal to a number. Therefore INT discards the decimal parts of a number.

Example:

SQR(9) is 3

INT(2.7) is 2

The terms in the parentheses can be numbers (as above), variables, or expressions.

ABS FUNCTION

Its full form is absolute. It is used to find the absolute value of a number. Absolute value of a number means the number without a sign.

Examples:

ABS(+3.4) = 3.4

ABS(- 3.4) = 3.4

RND FUNCTION

RND is a special function that gives us a random number between 0 and 1. This can be used in dice games to make it more interesting.

COS, SIN, TAN, ATN FUNCTIONS

COS (Cosine)

SIN(Sine)

TAN(Tangent)

ATN(Arctangent, inverse of TAN)

Example:

CONST pi =3.14

PRINT COS(pi/4)

PRINT SIN(pi/4)…….etc.

MOD FUNCTION

It means remainder. This function returns the remainder after division

Example:

16 MOD 5 = 1

30 MOD 5 = 0

EXP FUNCTION

The EXP function is used to calculate the exponential function i.e raise e to some power, where value of e is 2.13. The general form of exponential is EXP(X). e.g :

EXP(4) = 54.59815

EXP(-5) = 6.73794 E-03

LOG FUNCTION

LOG(X) gives the natural logarithm of X

MATHEMATICAL EXPRESSION BASIC NOTATION

(X -Y)/(X+Y) (X -Y)/(X+Y)

EXP (X^2 + Y) – SIN(X + N*y)

b =1/ 4ac B =1/ 4*A* C

- List five BASIC functions and what they do

Student are allowed to give corrections to the assessment given by the teacher ,while the teacher support s them in order to guide them.

## BASIC PROGRAMS

FIND SUQARE ROOT OF NUMBERS

10 REM FIND SUQARE ROOT OF NUMBERS

20 INPUT “ENTER FIRST NUMBER OF RANGE”; A

30 INPUT “ENTER LAST NUMBER OF RANGE”; B

40 FOR I = A TO B

50 PRINT “THE SUARE ROOT OF “; A; “IS “;SQR(A)

60 NEXT A

70 END

## FIND SQUARE ROOT OF S ROUNDED UP TO AN INTEGER

10 REM FIND SUQARE ROOT S

20 INPUT “ENTER NUMBER”; A

30 S = INT(SQR(A))

40 PRINT “THE SQUARE ROOT OF S ROUNDED OFF “;A; “IS “; S

50 END

## FIND THE COSINE OF KNOW VALUES

10 REM FIND TANGENT OF GIVEN ANGLE

20 INPUT “ENTER NUMBER”; A

30 S = TAN(A)

40 PRINT “THE TANGENT OF “;A; “IS “; S

50 END

## PLOT SINE WAVE CURVE

We can get the y position of the sine wave at any of these 360 points by using the SIN command. Unfortunately, the SIN command requires the input Radians but we can convert degrees to radians but multiplying the degrees by 0.017453. so to get the Y position of the sine wave at 90 degrees we would use this

## PRINT SIN(90*0.017453)

Of course using a scale of -1 to +1 is a bit limited in my opinion and it requires a bit of multiplication and addition so that we can get a range of something like 0 to 100 with 50 being the midpoint. To make this so:

10 PRINT (SIN (dg% *0.017453)*50)+50

20 SCREEN 13

30 FOR X%= 0 TO 360

40 PSET (X%, (SIN(X%*0.017453)*50)+50),15

50 NEXT X%

60 END

PLOT COSINE CURVE

20 SCREEN 13

30 FOR x% = 0 to 360

40 PSET (x%, (COS(x%*0.017453)*50)+50),15

50 NEXT x%

60 END

Related Posts:

Program Development | Qualities, Guidelines & Program Development Steps