
v0.40: Create exercises. Challenge the community.
Meet Studio →Write a function named replace_and_flip that processes a string and prints the result to standard output using write. All allocated memory must be freed before returning. Rules: - A word is a sequence of non-space characters separated by spaces. - If total words < 9 or total words is even (including empty or space-only strings), print a copy of the string followed by " \n". - If total words >= 9 and odd: 1. Replace 2nd word occurrences with case-flipped 6th word. 2. Replace 6th word with original 2nd word. 3. Insert (total_words + 2) after the middle word. 4. Print transformed string followed by " \n".
replace_and_flip("Run go fast go and lO jump go here");Expected result
Run Lo fast Lo and 11 go jump Lo here \nFor your own tracking. Tests grade your code.
replace_and_flip("one two three four five");Expected result
one two three four five replace_and_flip("one two three four five six seven eight nine ten");Expected result
one two three four five six seven eight nine ten replace_and_flip("a CAT b c d DOG e f CAT g h");Expected result
a dog b c d CAT 13 e f dog g h \nreplace_and_flip(" HELLO WORLD foo bar mid TEST baz WORLD end ");Expected result
HELLO test foo bar mid 11 WORLD baz test end \nExpected files
replace_and_flip.cAllowed functions
mallocfreewriteAllowed headers

Run the tests to grade your code
Build your code, then check each test here. Open a result to inspect its output.