pascal length function
In Pascal, you can use the Length
function to determine the length of a string. The Length
function takes a string as input and returns the number of characters in that string. Here's an example of how to use the Length
function:
program LengthExample;
var
myString: string;
len: Integer;
begin
myString := 'Hello, World!';
len := Length(myString);
writeln('The length of the string is: ', len);
end.
In this example, the variable myString
is assigned the value "Hello, World!" and the Length
function is used to determine the length of the string. The result is then stored in the variable len
. Finally, the length of the string is printed to the console using the writeln
function.
When you run this program, the output will be:
The length of the string is: 13
This indicates that the string "Hello, World!" has a length of 13 characters.