C - Write program to switch on character value

Requirements

Construct a program to make decision on the input the letters A, B, and C.

Demo

#include <stdio.h>

int main()//from  ww  w.  j  av a  2  s  .  com
{
    char code;

    printf("Enter the error letter (A, B, C): ");
    scanf("%c",&code);

    switch(code)
    {
        case 'A':
            puts("Drive Fault, not your fault.");
            break;
        case 'B':
            puts("Illegal format, call a lawyer.");
            break;
        case 'C':
            puts("Bad filename, spank it.");
            break;
        default:
            puts("That's not A, B, or C");
    }
    return(0);
}

Result

Related Exercise