0% found this document useful (0 votes)
22 views

String Library Functions

The document discusses various types of division and string library functions in BASIC. It defines modulo division as returning the remainder of an integer division. Integer division returns the quotient of integer division. Regular division divides numbers and returns a decimal result. String library functions like ASC(), CHR$(), LEN() allow manipulation of string values, converting between character codes and strings. Functions like LEFT$(), RIGHT$(), MID$() allow extracting parts of a string.

Uploaded by

Rahul
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

String Library Functions

The document discusses various types of division and string library functions in BASIC. It defines modulo division as returning the remainder of an integer division. Integer division returns the quotient of integer division. Regular division divides numbers and returns a decimal result. String library functions like ASC(), CHR$(), LEN() allow manipulation of string values, converting between character codes and strings. Functions like LEFT$(), RIGHT$(), MID$() allow extracting parts of a string.

Uploaded by

Rahul
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Modulo Division (MOD):

A MOD B means A is divided by B and remainder of division is returned. Here, both A and B must be integer
and the remainder is also an integer. E.g. 43 MOD 11 = 10
Integer Division (\):
A \ B means A is divided by B and quotient of division is returned. A and B are integers and the quotient is
also an integer. E.g. 43 \ 11 = 3
Division (/):
It is a binary operator which divides one number with the other. E.g. 43/11 = 3.909090

Library Function:
The built-in functions that are used for commonly used operations are called library functions. For e.g. ABS(),
INT(), SIN(), COS(), TAN(), SQR(), ASC(), CHR$(), LEFT$(), etc.

String Library functions:


a. ASC(): It returns a numeric value that is the ASCII code for the first character of the string.
Syntax : ASC(string expression)
E.g. : ASC(“A”) = 65
b. CHR$(): It is used to convert an ASCII code to the character it represents.
Syntax : CHR$(n) where n is a value from 0 to 255
E.g. : CHR$(65)=”A”
c. LEN():It returns the no. of characters in a string.
Syntax : LEN(string expression)
E.g. : LEN(“Mango”)= 5
d. STRING$(): It is used to obtain a string of length n composed entirely of the character whose ASCII code is m
or of the first character of x$.
Syntax : STRING$(n, m | x$)
E.g. : STRING$(5,”*”)= “*****”
e. VAL(): It converts a string expression consisting of digits into a numeric value.
Syntax : VAL(string expression)
E.g. : VAL(“5 Mangoes”) = 5
f. STR$(): It is used to convert numeric expression to its string representation.
Syntax : STR$(numeric expression)
E.g. : STR$(5)=”5”
g. SPACE$(): It is used to generate a string of spaces of length of n.
Syntax : SPACE$(n)
E.g. : SPACE$(5)=” “
h. LEFT$(): It is a string processing function that allows to remove the desired number of characters from the
left-hand side of the string.
Syntax : LEFT$(string expression, n)
E.g. : LEFT$(“Mango”,3) = “Man”
i. RIGHT$(): It is a string processing function that allows us to remove the desired number of characters from
the right-hand side of string.
Syntax : RIGHT$(string expression, n)
E.g. : RIGHT$(“Mango”,2) = “go”
j. MID$(): It is a string processing function which is used to extract number of characters from given position of
the string.
Syntax : MID$(string expression, start, length)
E.g. : MID$(“Mango”,2,3) = “ang”
k. LCASE$() and UCASE$(): These are used to convert string values to lowercase and uppercase respectively.
Syntax : LCASE$(string expression)
UCASE$(string expression)
E.g. : LCASE$(“Mango”)=”mango” and UCASE$(“Mango”)= “MANGO”

You might also like