1
function capital (word : string) : int
var count : int := 0
for i : 1 .. length (word)
if word (i) > "A" and word (i) < "Z" then
count += 1
end if
end for
result count
end capital
var word : string:="TEST"
put capital (word)
3
function mirror (word : string) : string
var mirr : string := ""
for decreasing i : length (word) .. 1
mirr := mirr + word (i)
end for
result mirr
end mirror
put "hi", mirror ("hi")
4
proc star (word : string, letter : string)
var newword : string := ""
for i : 1 .. length (word)
if word (i) = letter then
newword := newword + "*"
else
newword := newword + word (i)
end if
end for
put newword
end star
star ("gfhttheffthfe", "f")
5
var word : string
var output : string := ""
var ascii : int
function palindrome (var output : string) : string
var word2 : string := ""
put "Please enter a word/sentence"
get word : *
for i : 1 .. length (word)
if word (i) >= "A" and word (i) <= "Z" then
ascii := ord (word (i))
ascii += 32
output += chr (ascii)
elsif word (i) >= "a" and word (i) <= "z" then
output += word (i)
end if
end for
for decreasing i : length (output) .. 1
word2 := word2 + output (i)
end for
if output = word2 then
result "True"
end if
result "False"
end palindrome
put palindrome (output)