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