help how to count the remaining letters from the similar..

Example..

carl, 2
barbie, 4

#include<iostream.h>
#include<string.h>
#include<conio.h>
#include<stdio.h>
int findSimilar(char[],char[]);
void checkValue(int,int);
int main(){
	char boy[50];
	char girl[50];
	int similarInBoy=0;
	int similarInGirl=0;
	int total;
	clrscr();

	printf("Enter Boy's Name:  ");
	gets(boy);
	fflush(stdin);

	printf("Enter Girl's Name: ");
	gets(girl);
	fflush(stdin);

	similarInBoy=findSimilar(boy,girl);
	similarInGirl=findSimilar(girl,boy);
	total=similarInGirl+similarInBoy;


	printf("Boy: %i",similarInBoy);
	printf(",");
	checkValue(similarInBoy,1);
	printf("\n");

	printf("Girl: %i",similarInGirl);
	printf(",");
	checkValue(similarInGirl,2);
	printf("\n");

	printf("Total: %i",total);
	printf(",");
	checkValue(total,3);
	printf("\n");
	getch();
	return 0;
}

void checkValue(int similar,int gender){

	if(gender==1){
		if(similar>6)
			similar%=6;
		switch(similar){
		case 1:
			cout<<"Friend";
			break;
		case 2:
			cout<<"Love";
			break;
		case 3:
			cout<<"Affair";
			break;
		case 4:
			cout<<"Married";
			break;
		case 5:
			cout<<"Enemy";
			break;
		case 6:
			cout<<"Sweetheart";
			break;

		}
	}
	else if(gender==2){
		if(similar>6)
			similar%=6;
		switch(similar){
		case 1:
			cout<<"Friend";
			break;
		case 2:
			cout<<"Love";
			break;
		case 3:
			cout<<"Affair";
			break;
		case 4:
			cout<<"Married";
			break;
		case 5:
			cout<<"Enemy";
			break;
		case 6:
			cout<<"Sweetheart";
			break;
		}
	}
	else{
		if(similar>12)
			similar%=12;
		switch(similar){
			case 1:
			cout<<"Friends";
			break;
		case 2:
			cout<<"Lovers";
			break;
		case 3:
			cout<<"Affair";
			break;
		case 4:
			cout<<"Marriage";
			break;
		case 5:
			cout<<"Enemies";
			break;
		case 6:
			cout<<"Sweethearts";
			break;
		}
	}
}


int findSimilar(char firstName[],char secondName[]){
	int len;
	int len2;
	int similar=0;
	char ch1,ch2;
	char* first;
	char *second;

	first=strupr(firstName);
	second=strupr(secondName);
	len=strlen(firstName);
	len2=strlen(secondName);

	for(int ctr=0;ctr<len;ctr++){
		ch1=first[ctr];
		for(int ctr2=0;ctr2<len2;ctr2++){
			ch2=second[ctr2];
			if((ch1!=' ')&&(ch1==ch2)){
				similar++;
				break;
			}
		}
	}
	return similar;
	}

(length of string1 without spaces - similar count of string1 ) +
(length of string2 without spaces - similar count of string2)

This article has been dead for over six months. Start a new discussion instead.