Assignment 2.2: Letters

‘Letters’ Specification

Implement a program in C in a file called letters.c that does the following:

  • Get a string from the user
  • Print the # of characters in the string including spaces
  • Print the # of letters in the phrase (uppercase and lowercase)*
  • Print the # of words.* For these purposes, a word is only separated from other words by a single space. You can assume that any input given will not start or end with a space or contain groups of spaces (2 or more in a row).
  • Print the average word length (# of characters per word—round to 3 decimal places)
  • Print the input phrase with only the first letter of each word capitalized. All other letters should be lowercase even if they were upper in the input phrase.*

*write a function for each of these

References

In addition to the assigned lecture chunk, you might want to refer to the following:

Example in/out:

phrase: WORD
characters: 4
letters: 4
words: 1
average word length: 4.000
Word
phrase: TWO words!
characters: 10
letters: 8
words: 2
average word length: 4.000
Two Words!
phrase: in the aeroplane over the sea
characters: 29
letters: 24
words: 6
average word length: 4.000
In The Aeroplane Over The Sea
phrase: the last great american dynasty
characters: 31
letters: 27
words: 5
average word length: 5.400
The Last Great American Dynasty
phrase: Dr. Strangelove or: how I learned to stop worrying and love the bomb
characters: 68
letters: 54
words: 13
average word length: 4.154
Dr. Strangelove Or: How I Learned To Stop Worrying And Love The Bomb

Check & Submit

Check style with style50:

style50 letters.c

Check functionality with check50:

check50 cs-acs/problems/main/letters

Submit with submit50:

submit50 cs-acs/problems/main/letters