Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
program WordSubtraction;
procedure subtractWords(shortWord, longWord: string);
var
count: integer;
result: string;
begin
for count := 1 to length(shortWord) do
result := concat(result, chr((ord(longWord[count]) - ord(shortWord[count]) + 25) mod 26 + 65));
result := concat(result, copy(longWord, length(shortWord) + 1, length(longWord) - length(shortWord) - 1));
writeln('Result: ', result);
end;
procedure main();
var
word1, word2: string;
begin
write('Enter a word: ');
readln(word1);
write('Enter another word: ');
readln(word2);
if length(word1) > length(word2) then
subtractWords(upcase(word2), upcase(word1))
else
subtractWords(upcase(word1), upcase(word2));
end;
begin
main();
readln;
end.
Advertisements
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.
AcceptLearn more