Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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.
20th May 2022, 12:44 PM
Jayakrishna 🇮🇳
+ 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);
20th May 2022, 12:34 PM
Jayakrishna 🇮🇳
+ 1
You're welcome..
20th May 2022, 1:45 PM
Jayakrishna 🇮🇳
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)
20th May 2022, 11:44 AM
Alexus100
Alexus100 - avatar