+ 2
By testing your code!
You know int/int result int only..
So argument to ceil is int value, and it returns same value. No effect. Need a double value to get double type result in division.
+ 1
Manav Roy
length -= SpecialChars;
After the correction, convert length or NoOfWords as double type or declare as double type.
Use like this :
cout<<ceil((double)length/NoOfWords);
+ 1
You're welcome..
0
I guess, you've forgot to substract number of special symbols from length of sentence in final answer:
ceil((length-SpecialChars)/NoOfWords)
But anyway, easier way to do this task is just divide number of letters (those, for which isalpha is 1) by number of spaces, increased by one (which indicates number of words):
LettersCount / (SpacesCount + 1)