Information Technology Reference
In-Depth Information
and the statements
y = “8”
answer = index (y, x)
which will result in
answer
with the value of 0 because the character 8 is not in the string
01234567.
Before proceeding recall that
integer
represents a one position numeric field just as the use of
character
for middle initial in an earlier program involved a single character.
The statements
z = “222”
answer = index (z, x)
will yield a value of 1 for
answer
since each character in the variable
z ,
namely the 2 three times, is in the variable
x .
If we have the statements
z = “70”
answer = index (z, x)
note that the result will be 0. Certainly the 7 and the 0 are in the variable
x
but the third character is not. The last character is a space since
z
is defined as 3 characters and the statement
z = “70”
results in
z
consisting of three characters with the last one being a space. Since the space is not found
in the string
x ,
the result of the
index
Search WWH ::




Custom Search