0

Write a program that will enter the string from the user and count the number of words????plz help me

15th Jan 2017, 11:31 AM
Zain Rafeeq
Zain Rafeeq - avatar
3 ответов
+ 4
in a loop, keep reading the next character. if the character is a separator, increment the word count and keep reading until the next non-separator is found.
15th Jan 2017, 8:15 PM
ifl
ifl - avatar
+ 3
@Joshnu : counting number of whitespaces will give a wrong number of there are more that one whitespace between words.
15th Jan 2017, 8:11 PM
ifl
ifl - avatar
0
check for whitespaces as a white space separates word. and fullstops in case of sentences. if(a[i]==' ') count++;//inside a for loop, count indicates the no of white spaces, is words. hope this helps
15th Jan 2017, 11:54 AM
Jishnu Jayarajan