Computer for SEE and NEB

It is a complete SEE and NEB solution for computer science. It includes Computer Fundamentals, Database (SQL), Programming in C QBASIC, CSS, JavaScript, and PHP for beginners.

Breaking

Post Top Ad

Your Ad Spot

Wednesday, February 16, 2022

Numeric/mathematical library function in QBASIC

 

Numeric / Mathematical 

Library Functions


A numeric function is a function that processes upon the numeric data.  When they are called, they return a single value that can be either an integer or a single precision data type. Following are the different types of numeric functions.

 

 INT

It is a mathematical function which display the number without integer.

 Syntax:  INT (numeric expression)

Example:

CLS

REM example of INT function

PRINT INT(14.4)

PRINT INT(-65.4)

END

Output

 


 

 

SQR

It is used to obtain the square root of an argument. The argument must contain positive expression.

 

Syntax: SQR (numeric expression)

Example:

REM Example of SQR function

CLS

PRINT SQR(121)

LET a = 9

PRINT SQR(a)

END

Output



 

  ABS

It is a math function that returns the absolute value of a numeric expression. A number’s absolute is its value without a “+” or”-“sign.(it also returns –ve number into +ve number) Syntax:  ABS(numeric expression)

Example:

REM Example of ABS function.

CLS

PRINT ABS(67.8)

PRINT ABS(-12.4)

PRINT ABS(4 - 6)

END

 Output



 

 

CINT

This statement converts a numeric expression to an integer by rounding the fractional part of the expression.

Syntax: CINT (Numeric expression)

Example:

REM Example of CINT function

CLS

PRINT CINT(23.545)

PRINT CINT(23.234)

END

Output



 

 

SGN

It is a numeric function that indicates the sign of numeric expression.

If the numeric expression is positive, it returns 1

If the numeric expression is negative, it returns -1

If the numeric expression is zero, it returns 0

Syntax: SGN(numeric expression)

Example:

REM Example of SGN function

CLS

PRINT SGN(10)

PRINT SGN(-10)

PRINT SGN(0)

END

Output



 

 

FIX

It is a mathematical function that returns the integer part of a numeric expression after remove decimal part.

Syntax: FIX(numeric expression)

Example:

REM Example of FIX function

CLS

PRINT FIX(-34.67)

PRINT FIX(21.78)

END

Output



 

SIN, COS and  TAN

SIN function gives sin, COS function gives cosine and TAN function gives tangent of given angle.

 

Syntax: SIN(angle)

               COS(angle)

              TAN(angle)

Example:

REM Example of SIN, COS and SIN function.

CLS

PRINT SIN(45)

PRINT COS(45)

PRINT TAN(45)

END

Output



 

 

EXP

This function is used to calculate the exponential of given numeric expression. It gives e raised to a given power, where e is the natural logarithm.

Syntax: EXP(numeric expression)

Note: Numeric expression which must be less than or equal to 88.02969

Example:

REM Example EXP function

CLS

PRINT EXP(0)

PRINT EXP(4)

END

 Output



 

 Also Read: Array in QBASIC for class 9 and 10


LOG

This function gives the natural logarithm of the given numeric expression.

Syntax:  LOG(numeric expression)

Example:

REM Example of LOG function

CLS

PRINT LOG(1)

PRINT LOG(4)

END

Output





You may also Read:

No comments:

Post a Comment

Post Top Ad

Your Ad Spot

Pages