Search This Blog

Translate

accept two string and remove common character in both string and display remaining string

accept two string and remove common character in both string and display remaining string


#include<stdio.h"
#include"conio.h"
void main()
{
char ch1[10],ch2[10];
int i,j,flag;
clrscr();
printf("Enter the first string=");
gets(ch1);
printf("\n\nEnter the second string=");
gets(ch2);
printf("\n\nFirst string after remove common character=");
for(i=0;i"ch1[i]!='\0';i++)
{
  flag=0;
  for(j=0;j"ch2[j]!='\0';j++)
{
if(ch1[i]==ch2[j])
{
flag=1;
      break;
}
}
if(flag==0)
{
printf("%c",ch1[i]);
}
}


printf("\n\nSecond string after remove common character=");
for(i=0;i"ch2[i]!='\0';i++)
{
flag=0;
for(j=0;j"ch1[j]!='\0';j++)
{
if(ch2[i]==ch1[j])
{
flag=1;
break;
}
}
if(flag==0)
{
printf("%c",ch2[i]);
}
}
getch();
}


accept two string and remove common character in both string and display remaining string

C Program example List

Google+ Badge