# Library Functions in QBASIC-Introduction Introduction: A function is a built-in formula or a ready made program which helps us to perform a certain task such as mathematical, financial, logical etc. A function manipulates data passes to it and returns either a string or a numeric. There are two types of functions:

1. User defined function
2. Built in function

1. User defined function: It is created by the programmer to perform the operations as per the requirements. It can be numeric or string function. To define a function DEF FN is used and it must be executed before the function.

Syntax: DEF FNname (parameter list)=expression

2. Built-in function: It is pre-defined program which is provided by QBASIC to perform some task easily. It gives many more built-in functions for manipulating strings, numbers. It makes our work easy. The values provided are called arguments and it can accept more than one arguments. And the value which is returned is called its return value. There are two types of built in function:

-Numeric functions            – String Functions

a) Numeric functions: It provides a faster way to evaluate many mathematical functions.  Some of them are:

• ABS function : It returns corresponding positive value. General form: ABS(x)
• CINT function: It returns nearest numeric expression from -32768 to 32767 as argument. General form: CINT(x)
• COS function: It is used to obtain the cosine of x.  General form: COS(x)
• INT function: It returns an integer that is smaller then or equal to a numeric expression. General  form: INT(x)
• SIN function: It is used to get the sine of x. General form: SIN(x)
• SGN function: It is used to return the sign of numeric expression. General form: SGN(x)
• SQR function: It is sued to calculate and return the square root of non-negative number. General   form: SQR(x)
• TAN function: It is used to get the tangent of x. General form: TAN(x)

b) String functions: It is used to operate and manipulate on string.  Some of them are:

• ASC function: It returns the ASCII code corresponding to the character of string. General form :    ASC(string)
• CHR\$ function : It returns a character that corresponds to specific ASCII values in between -128  and 127 as arguments. General form: CHR\$(m)
• INSTR\$ function: It searches for one string inside another and returns the position of first character. General form: INSTR([m,]x\$,y\$)
• LEN function: It counts and returns the total number of characters in a string. General form:           LEN(v)
• LEFT\$ function: It is used to extract and return the numbers of characters from the left of a string. General form: LEFT\$(expression,x)
• RIGHT\$ function: It is used to extract and return the numbers of characters from the right of a string. General form: RIGHT\$(expression,y)
• MID\$ function: It is used to replace the part of the string variable with another. General form: MID\$(expression,start,length)
• SPACE\$ function: It returns a string of spaces of a specified length. General form: SPACE\$(x)
• STR\$ function: It converts a numeric expression to string and returns the same. General form: STR\$(x)
• STRING\$ function:It returns a string of a specified length made up of a repeating character.General form: STRING\$(x,y | z\$)
• LCASES\$ and UCASES\$ function: It converts string values to lowercase and uppercase respectively. General form : LCASES\$(expression) and UCASES\$(expression)
• DATE\$ and TIME\$: It retrieve the current date and time respectively. General form: DATE\$=String and TIME\$=String View all posts by Prajwal Rai →

### 3 Comments on “Library Functions in QBASIC-Introduction”

1. Sulav Sapkota says:

Excuse Me Sir but in Built-In Functions you have mentioned that there are 3 types of it but downside you have explained only two. I didn’t get that.🤔🤔

1. Prajwal Rai says:

Thank you for your concern Sulav. Its two types not three. 🙂

2. ASHIRBAD Rai says: