String Manipulations

Function for finding a substring

function sub ( string s, int pos, int num, string result)
{
// This function takes a substring of the string s, starting
// at position pos for num characters and returns
// it in the parameter result.

int len; // length of the string
int j, k, m; // indexes

// check if the value of pos or num is out of bounds

len = length(s)
{
if (( pos <= 0 ) or ( num <= 0 ) or ( pos > len ))

Algorithm

What is an Algorithm ?

An algorithm is any well-defined computational procedure that takes some value, or set of values, as input and produces some value, or set of values, as output.

An algorithm is thus a sequence of computational steps that transform the input into the output.