<prompt> Kuandika C kazi kutatua: Kutokana na kamba s, kurudi idadi ya sehemu katika kamba. Sehemu ni maalum kuwa mfululizo contiguous ya wahusika non-space.  <response>: Heres a possible implementation:int countSegmentsstring s int count 0; bool inSegment false; for char c : s if c ! if !inSegment inSegment true; count; else inSegment false; return count;This function initializes a count variable to zero and a boolean flag inSegment to false. Then, it iterates over each character in the input string s. If the character is not a space and were not already in a segment, we start a new segment and increase the count. Otherwise, if the character is a space, we end the current segment. Finally, we return the count. 