Remove S2 Characters from S1 ID:5398



Two string values S1 and S2 are passed as input to the program. The program must remove all the characters that are present in S2 from S1 and print the resulting string value as the output.

Boundary Condition(s):
1 <= Length of S1 <= 1000
1 <= Length of S2 <= 1000

Input Format:
The first line contains S1.
The second line contains S2.

Output Format:
The first line contains the string value.

Example Input/Output 1:
Input:
apple
pan

Output:
le

Example Input/Output 2:
Input:
economical
mango

Output:
ecicl

Program in C:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
 int check(char a[],char z)
 {
     for(int i=0;i<strlen(a);i++)
     {
         if(z==a[i])
         return 1;
     }
     return 0;
 }
int main ()
{
    char s1[1000], s2[1000];
    scanf("%s",s1);
    scanf("%s",s2);
   for(int i=0;i<strlen(s1);i++){
      if(!check(s2,s1[i]))
      {
       printf("%c",s1[i]);   
      }
   }
 
    return 0;
}

Comments

Popular Posts