IHYPRESS PROGRAMMING
Tutorials and C programs with code and output for beginners
c programming
HOME | ASP | C | CSS | GNUPLOT | HTML | JAVASCRIPT | PERL | PHP | PYTHON | RUBY | SVG
CSelection Structures : Warship Classification
<03.10>
/* the warship program */ /* uses the switch statement */ #include <stdio.h> int main(void) { char class; /* the ship's class */ /* Read first character of serial number */ printf("Enter ship serial number > "); scanf(" %c", &class); /* Display 1st character and ship class */ printf("Ship class is %c: ", class); switch (class) { case 'B': case 'b': printf("Battleship\n"); break; case 'C': case 'c': printf("Cruiser\n"); break; case 'D': case 'd': printf("Destroyer\n"); break; case 'F': case 'f': printf("Frigate\n"); break; default: printf("Unknown\n"); } return (0); }
Hergestellt in Deutschland / Made in Germany
Enter ship serial number > DDG-983 Ship class is D: Destroyer
COPYRIGHT © 2015-2024 IHY PRESS Frankfurt am Main 60329 Deutschland