Using switch statements, reads input up to #, replaces each period with an exclamation mark - C Statement

C examples for Statement:switch

Introduction

Replaces each exclamation mark initially present with two exclamation marks, and reports at the end the number of substitutions it has made.

Demo Code

#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;
}

Result


Related Tutorials