Microsoft Interview Question

Write a function that outputs the number of words in a string.