program function_totalwords; uses crt; var Z : text; t_v,t_ca,t_c,t_l,t_w,t_p : integer; line : char; s,fil : string; stop : char; procedure read_file; var i, space : integer; begin space :=0; while not eof(Z) do begin read(Z, line); if line <> '' then t_c := t_c+1; if line in ['a','A','E','e','i','I','o','O','U','u'] then t_v := t_v +1; if line = ' ' then space := space+1; if line in ['a'..'z','A'..'Z'] then t_l := t_l +1; if line in ['A'..'Z'] then t_ca := t_ca +1; if eoln(Z) then t_p := t_p +1; end; if t_c <> 0 then t_w := space + t_p else t_w := 0; end; function search_ex(st : string) : integer; var sel,s, f_s,f_s_t : string; search : char; i,j,k,y : longint; begin j := 1; y := 0; k := t_c; while (j <= k+1) and (st<>'') do begin assign(z,fil); s[0] := st[0]; reset(z); for i := 1 to j-1 do read(z,search); for i := 1 to ord(st[0]) do read(z,s[i]); close(z); if s=st then y := succ(y); j:=j+1; end; search_ex:=y; end; begin write('Enter the text file: '); readln(fil); assign(Z , fil); reset(Z); t_v := 0; t_c := 0; t_l := 0; t_w := 0; t_p := 0; t_ca := 0; read_file; close(Z); stop := '0'; while stop <> '7' do begin stop := '0'; clrscr; writeln('Text analysis'); writeln('================================'); writeln('1. Count word(s)'); writeln('2. Count paragraph(s)'); writeln('3. Count letter(s)(a to z and A to Z)'); writeln('4. Count captial letter(s)'); writeln('5. Count vowel(s)'); writeln('6. Count frequency(ies) of a expression'); writeln('7. Exit'); writeln('================================'); write('Choice:'); repeat readln(stop); until stop in ['1'..'7']; case stop of '1':writeln('This composition has ', t_w, ' word(s).'); '2':writeln('This composition has ', t_p, ' paragraph(s).'); '3':writeln('This composition has ', t_l, ' letter(s).'); '4':writeln('This composition has ', t_ca, ' captial letter(s).'); '5':writeln('This composition has ', t_v ,', vowel(s).'); end; if stop = '6' then begin writeln('Input the expression you want to check the frequencies'); readln(s); writeln('''',s,'''',' appers ',search_ex(s),' times.'); end; if stop <> '7' then stop := readkey; end; end.