begin writeln′Enteratext:′'Enter a text: '′Enteratext:′; readlntexttexttext;
count := 0; i := 1;
while i <= lengthtexttexttext do begin if textiii <> ' ' then begin count := count + 1; while (i <= length(text)) and (text[i] <> ' ') do i := i + 1; end else i := i + 1; end;
writeln′Numberofwordsinthetext:′,count'Number of words in the text: ', count′Numberofwordsinthetext:′,count; end.
program WordCount;
var
text: string;
count, i: integer;
begin
writeln′Enteratext:′'Enter a text: '′Enteratext:′;
readlntexttexttext;
count := 0;
i := 1;
while i <= lengthtexttexttext do
begin
if textiii <> ' ' then
begin
count := count + 1;
while (i <= length(text)) and (text[i] <> ' ') do
i := i + 1;
end
else
i := i + 1;
end;
writeln′Numberofwordsinthetext:′,count'Number of words in the text: ', count′Numberofwordsinthetext:′,count;
end.