Flames Program to find relationship

Question:
Write a program to implement flames concept in any language.
Logic:
- Get the two names from the user.
- Eliminate the matching characters by comparing the names.
- After elimination calculate the sum of the length of both names.
- Then remove characters in FLAMES by applying conditions.
- And then print the relation using the last character in FLAMES.
Algorithm:
- Get the two strings from the user.
- Add the length of the two names.
- Check the matching elements in two words and decrement length by two.
- Then eliminate characters in FLAMES by applying conditions.
- By using the last element in FLAMES print the relation.
Program:
[code lang=”c”]
void main()
{
char a[100],b[100],c[6]="FLAMES",g;
int p,q,r,i,j,k,l,e,d=6,f;
printf("Enter the first name:\n");
gets(a);
printf("Enter the second name:\n");
gets(b);
p=strlen(a);
q=strlen(b);
r=p+q; //add the length of two names
f=d;
printf("the flames between two is");
for(i=0;i<p;i++)
{
for(j=0;j<q;j++)
{
if(a[i]==b[j]) //checks the elements in two words if equal subtract two from r
{
r=r-2;
break;
}
}
}
for(k=0;k<f-1;k++)
{
e=r%d;
if(e==0)
{
e=d-1;
}
else
{
e=e-1;
}
for(l=e;l<d;l++) //delete the letters in FLAMES
{
c[l]=c[l+1];
}
d–;
}
g=c[0]; //gets the last letter remains
switch(g) //prints the relationship between two
{
case ‘F’:
printf("friends");
break;
case ‘L’:
printf("love");
break;
case ‘A’:
printf("affection");
break;
case ‘M’:
printf("marriage");
break;
case ‘E’:
printf("enemy");
break;
case ‘S’:
printf("sister");
break;
default:
printf("nothing");
}
getch();
}
[/code]