2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by Vega_Knight
2

see if this help:

Program CountingWords;
Uses WinCrt;
Var JumPhrase : Integer;
Phrase : String;
Ul : Char;
Procedure CheckWords(Teks: String; Var CW: Integer);
Var i: Integer;
Begin
	If (Teks[1]=' ') Then
		CW:=0
	Else
		CW:=1;
	For i:= 1 To Length(Teks) Do
	Begin
		If (Teks[i]=' ') And (Teks[i+1]<>' ') And (Teks[i+2]<>' ') Then
		Inc(CW)
		Else If (Teks[i]='-') And (Teks[i-1]<>' ') And (Teks[i+1]<>' ')
		Then
		Inc(CW);
	End;
End;
Begin
	Repeat
	Clrscr;
	Writeln('Counting Words');
	Writeln('============================================');
	Writeln;
	Writeln('Input Sentences:');Readln(Phrase);
	CheckWords(Phrase,JumPhrase);
	Writeln;
	Writeln('Number of words in the sentence is : ',JumPhrase,' Pieces');
	Writeln;
	Write('Try Again [Y/N]: ');Ul:=Upcase(Readkey);
	Until Ul<>'Y';
End.
Votes + Comments
working like a charm.
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.