# Mia and String Matching

QUESTION

Mia in a Tech competition was assigned a task for writing a function to determine how closely two words resemble each other. \n\nHow will Mia do this task?\n\nExample, the words \”TICK\” and \”TOCK\” have a score of 3, since three characters (T, C, K) are the same.\n\nSimilarly, \”CAT\” and \”DOG\” score 0, since no letters match.\n\nYou are given Strings A and B and you have to return an integer K indicating the score (as defined above) of how closely the two match.\n\nInput :\n\nFirst line of input contains an integer T denoting the number of test cases. Each test case contains two lines of input, where first line contains the string A and second line contains the string B.\n\nOutput :\n\nFor each test case print the score on a line.\n\nConstraints :\n\nA and B will each contain between 1 and 500 characters, inclusive.\nEach character of a and b will be ‘A’-‘Z’.\n1 <= T <= 50.

``````#include <stdio.h>
#include<string.h>

int main(void) {
int t,i,a,b,c;
char str,str2;
scanf("%d",&t);
while(t--)
{
c=0;
scanf("%s",str);
scanf("%s",str2);
a = strlen(str);
b = strlen(str2);
if(a>=b)
{
for(i=0;i<b;i++)
{
if(str[i]==str2[i])
c++;
}
}
else if(a<b)
{
for(i=0;i<a;i++)
{
if(str[i]==str2[i])
c++;
}

}
printf("%d\n",c);
for(i=0;i<b;i++)
str2[i] = '\0';
}
return 0;
}`````` 