program HitungKata;
uses wincrt;
type
nomor = 1..21;
Larik = array[nomor] of char;
const
Kalimat : Larik = ('W','H','E','N',' ','S','A','N','K','A','L','A',' ','T','A','L','K','I','N','G','.');
var
x,jumlah : integer;
begin
if Kalimat[1] = '.' then writeln('Ini teks kosong!') else
begin
x := 1;
jumlah := 1;
while Kalimat[x] <> '.' do
begin
write(Kalimat[x]);
if (Kalimat[x] = ' ') and (Kalimat[x-1] <> ' ') then jumlah := jumlah+1;
x := x+1;
end;
end;
writeln;
writeln ('**************************') ;
writeln('Katanya Berjumlah : ',jumlah,' buah');
writeln ('**************************') ;
end.
Ini Hasil setelah programnya di running :
0 komentar:
Post a Comment