(* Teresa Tong F.4AS [30] March,2002 *)
(* Write a program that reads in a name consisting of a
surname and a first name, and then prints the initials,
each followed by a full stop *)
Program extract_name;
uses wincrt;
var a,name,name1,name2,name3,name4,name5:string;
i:integer;
begin
Writeln('Enter your name: ');
Readln(a);
i:=1;
repeat
name1:=name1+a[i];
i:=i+1;
until a[i]=' ';
i:=i+1;
repeat
name2:=name2+a[i];
i:=i+1;
until a[i]=' ';
i:=i+1;
repeat
name3:=name3+a[i];
i:=i+1;
until i=length(a)+1;
name4:=copy(name2,1,1)+'.';
name5:=copy(name3,1,1)+'.';
name:=name4+name5+name1;
writeln('The short form of your name is: ',name);
end.
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
Output:
1) Enter your name:
Chan Tai Man
The short form of your name is: T.M.Chan
2) Enter your name:
Wong Mei Ling
The short form of your name is: M.L.Wong
               (
geocities.com/ttt_7_ttt)