The_ARA
asked on
Pascal assignment , need help :(
Write a program that;
Prompts and permits the user to enter a phrase.
Prompts and permits the user to enter a word.
Reveals the number of times that the word occurs in the phrase. (N.B. Words within words do not count).
ive tried so far
program INPHRASE;
uses crt;
var
word : string;
phrase : string;
i : integer;
c : integer;
begin
clrscr;
write('Enter a phrase : ');
readln(phrase);
writeln;
write('Enter a word : ');
readln(word);
c :=0;
for i := 1 to length(phrase) Do
if phrase[i] = word then c := c+1;
writeln;
writeln('Found word "'+word+'" in phrase "'+phrase+'" ',c,' times.');
readln;
end.
Please help
Prompts and permits the user to enter a phrase.
Prompts and permits the user to enter a word.
Reveals the number of times that the word occurs in the phrase. (N.B. Words within words do not count).
ive tried so far
program INPHRASE;
uses crt;
var
word : string;
phrase : string;
i : integer;
c : integer;
begin
clrscr;
write('Enter a phrase : ');
readln(phrase);
writeln;
write('Enter a word : ');
readln(word);
c :=0;
for i := 1 to length(phrase) Do
if phrase[i] = word then c := c+1;
writeln;
writeln('Found word "'+word+'" in phrase "'+phrase+'" ',c,' times.');
readln;
end.
Please help
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Maybe you're able to scan for the Word expression in a string with POS.
Then copy the Rest of the String
Now Repat Expression scan and rest-copy process till the end of String.
Do this like you want!
I'm sure you're able to.
Then copy the Rest of the String
Now Repat Expression scan and rest-copy process till the end of String.
Do this like you want!
I'm sure you're able to.
Maybe you're able to scan for the Word expression in a string with POS.
Then copy the Rest of the String
Now Repat Expression scan and rest-copy process till the end of String.
Do this like you want!
I'm sure you're able to.
Then copy the Rest of the String
Now Repat Expression scan and rest-copy process till the end of String.
Do this like you want!
I'm sure you're able to.
I suppose that for a "homework help" it's enough to provide almost-good solutions ;-)