Handling the Last word separately
NumberOfWords ++ ; if ( sum < k ) counter ++ ; cout << " Number ▁ of ▁ words ▁ having ▁ sum ▁ of ▁ ASCII " " ▁ values ▁ less ▁ than ▁ k ▁ = ▁ " << counter << endl ; cout << " Number ▁ of ▁ words ▁ having ▁ sum ▁ of ▁ ASCII ▁ values " " ▁ greater ▁ than ▁ or ▁ equal ▁ to ▁ k ▁ = ▁ " << NumberOfWords - counter ; }