What Is Wrong In My Code Coach Averange Code Length | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What Is Wrong In My Code Coach Averange Code Length

#include <iostream> #include <string> #include <cmath> using namespace std; int main(){ string kata; string awe; float huruf = 0 , spasi = 0; getline(cin,kata); for(int i=0;i<kata.length();i++){ awe = kata[i]; if(awe != " "){ huruf++; }else if(awe == " "){ spasi++; } } cout << ceil((huruf)/(spasi+1)) << endl; return 0; } What is wrong in my code

30th Dec 2020, 12:21 PM
Alex
Alex - avatar
1 Answer
+ 1
Your program counts punctuations also. Which according to the question statement should be removed from the input before evaluation
30th Dec 2020, 12:39 PM
Arsenic
Arsenic - avatar