Saturday, August 18, 2018

REMOVE ALL OCCURRENCE


  • Problem Description

    C program to remove all occurrences of a character from the string
  • CODING ARENA
  • #include <stdio.h>
    #include<string.h>
    int main()
    {
      char str[10];
      char ch;int i,size;
      scanf("%s %c",str,&ch);
      size=strlen(str);
      for(i=0;i<size;i++)
      {
        if(str[i]!=ch)
          printf("%c",str[i]);
      }
      return 0;
    }
     
      

      
  • Test Case 1

    Input (stdin)
    madam
    
    a
    
    
    Expected Output
    mdm
  • Test Case 2

    Input (stdin)
    SRMSRMSRM
    
    S
    
    
    Expected Output
    RMRMRM

No comments:

Post a Comment