+ 2
Can some one help me debug my code it in the challenge of average word length?
My problem is when i calculate the average word length of test case using a calculator i get 4.4286 .Which is four in interger but the answer they are saying is 5 but test case 1 and 4 are right but the others its sayi is wrong https://code.sololearn.com/crvLiIp29RTA/?ref=app
4 Respuestas
+ 2
I have solved it by checking if th average word length divided by number of word has a remeinder if not average word length will be whole number if yes average word length is added by on
float ans=word_length/(count+1);
// prints average word length
if((word_length%(count+1))!=0){
cout<<++ans;}
else{
cout<<ans;}
The code at the end !!
+ 2
Reading the task description again will help.
+ 2
https://code.sololearn.com/crvLiIp29RTA/?ref=app
After fixing it
+ 1
But thanks for your advice it really helped