YCP Logo Lab 14: Input character classifier

Getting started

If you have a solution open in Visual Studio, close it (File->Close Solution).

Download CS200_Lab14.zip. Import it into Visual Studio (File->Import...).

Add your code to the source file called Classifier.c.

Your task

Write a program that reads each character from standard input (i.e., the input typed by the user) and determines which of the following categories the character belongs to:

  • Upper case letter
  • Lower case letter
  • Digit
  • Whitespace
  • None of the above

Your program should keep a running count of the number of characters seen falling into each category.

When the user closes the standard input by typing Control-Z followed by Enter, the program should print a summary of how many characters were counted in each category.

Example run (user input in bold):

Now is the winter of our discontent.
Four score and seven years.
OK, l8r dude.
The input contained:
4 upper case letters
55 lower case letters
1 digits
15 whitespace characters
5 characters that didn't fall into the above categories


The program should contain a loop that looks something like this:

while (!feof(stdin)) {
    int ch;

    ch = getchar();

    if (ch >= 0) {
        /* classify the character whose character code is stored in ch */

In the above loop, the condition


yields a true value if there are more characters to read from the keyboard, false otherwise.

You can determine whether or not a character value is a "whitespace" character (space, tab, newline, etc.) by testing the condition


where ch is the value of the character you want to test.

You will need one accumulator variable for each character category.


When you are done, choose Tools->Submit to submit your completed lab to the server. You will need to enter your Marmoset username and password.

If the Tools->Submit option does not work, create a zip file containing the files in your project, and upload it to the submission server as lab14. The server URL is