Given two first names of two persons, please calculate names Name
• Ifa letter occurs in the same position in both names screens
if a letter occurs in both names but in different posters meses
• Once a letter is used in any of the names it cannot be considered an
1
input: The first line contains the first name & the second line certains some
Output: Only an integer value showing the name promoure
Answers
Program:
#include <stdio.h>
void strchng(char *str);
int main()
{
int count=0;
char fn1[1000],fn2[1000];
scanf("%s",fn1);
scanf("%s",fn2);
strchng(fn1);
strchng(fn2);
for(int i=0; fn1[i]!='\0'; i++)
{
for(int j=0;fn2[j]!='\0'; j++)
{
if(fn2[i]!='0' && fn1[i]==fn2[j])
{
if(i==j)
count=count+2;
else
count=count+1;
fn2[j]='0';
}
}
}
printf("%d",count);
return 0;
}
void strchng(char *str)
{
int k=0;
while(str[k]!='\0')
{
if(str[k]>='A' && str[k]<='Z'){
str[k]=str[k]+32;
}
++k;
}
}
Test cases:
Input 1:
Amitabh
Ajitabh
Output 1:
12
Input 2:
Ryaan
Nagesh
Output 2:
2
Learn more:
1. Write a program to check whether it is a Lead number or not in java
https://brainly.in/question/15644815
2. Write a java program to input name and mobile numbers of all employees of any office. Using "Linear Search", search array of phone numbers for a given "mobile number" and print name of employee if found, otherwise print a suitable message.
brainly.in/question/18217872