C examples for Statement:switch
Replaces each exclamation mark initially present with two exclamation marks, and reports at the end the number of substitutions it has made.
#include <stdio.h> #define STOP '#'/*from w ww . j a v a 2 s .c o m*/ int main(void){ char ch; printf("Enter input (%c to exit):\n", STOP); while ((ch = getchar()) != STOP){ switch (ch){ case '.' : printf("!"); break; case '!' : printf("!!"); break; default : printf("%c", ch); } } return 0; }