• Courses
• Data Structure

Mathematical Library Functions (QBASIC)

The functions which are used to process the numeric data are called mathematical functions. Mathematical library functions of QBasic are described below with examples.

SQR

It calculate and return the square root of non-negative number.

Example:

``````CLS
PRINT SQR(144)
END
``````

Output

``````12
``````

MOD

It returns reminder, when one number is divided by another number.

Example:

``````CLS
PRINT 9 MOD 5
END
``````

Output

``````4
``````

INT

It returns an integer of a give number.

Example:

``````CLS
n = 27.5
PRINT INT(n)
END
``````

Output

``````27
``````

CINT

It returns nearest rounding numeric value from -32768 to 32767 as argument.

Example:

``````CLS
PRINT CINT(3.49)
PRINT CINT(3.51)
END
``````

Output

``````3
4
``````

SGN

It returns the sign of numeric value. If the number is positive it returns 1, if the number is negative, it returns -1 and if the number is 0 it returns 0.

Example:

``````CLS
PRINT SGN(15)
PRINT SGN(-15)
PRINT SGN(0)
END
``````

Output

``````1
-1
0
``````

ABS

It returns corresponding positive value.

Example:

``````CLS
PRINT (-15.3)
END
``````

Output

``````15.3
``````

SIN, COS & TAN

SIN, COS and TAN returns sign value, cosine value and tangent value respectively.

Example:

``````CLS
PRINT SIN(1.5)
PRINT COS(1.5)
PRINT TAN(1.5)
END
``````

Output

``````.997495
.0707372
14.10142
``````

sdf

327

Recent MCQs

 MS-Excel Quick Tip 2 MS-Excel Quick Tip 1 MS-Word Quick Tip 3 MS-Word Quick Tip 2