 Hey everyone, today we are going to see the programs using function call by value learning outcome at the end of this session students will be able to write a C program using function call by value. Now before string this video students must watch the following videos on the function. So now in this session we see the problem statement write a C program to check whether the two given strings are an anagram or not using function. The first of all we see what is mean by anagram. Anagram is a theme but it is another string that string contains the same character but the order of the string is different. So here you can see that the first so here you can see that the first string is spare and the second string is peers. So here the anagram means what the spare and the peers the peer string is formed by it is having the same characters but the order of the character is different. So here S is there, after that P is there, A is there, R is there, E is there and in the peers first P is there, after that E is there, A is there, R is there, S is there means anagram string is nothing but it is a another string and that string is formed by containing the same characters but the order of the character is different. So here P comes first then E comes next then A comes next then R and S. In the original string in the spare the S is first after that P is there, after that A is there, after that R is there and then E is there. So here spare and peers are anagram. So we will see this program on code block. So first of all here we include the header files, here I will take one function check anagram. The return type of that function is integer. It takes two parameters of type character because we need the two string. So here we declare the two character parameters, the name of the variable is str1 and str2 and it is the end with semicolon because it is a function declaration. After that we see the main function. In the main function we require the two string. So here in C we know that string is declared by using the character array. So here the data type is character, str1 is a character of one array and str2 is a second array for storing the two string. So after that we display the printf statement input the first string and then we use the fgettas function for taking the input from the user. Next we use the another printf statement for reading the second string from the user and again here we use the fgettas function. So here first we use the if decision control statement in here if check anagram. Check anagram function is called and here we pass the two string str1 and str2. If both the strings are equal to one then str1 is assigned to the value slash 0 but here we calculate the length of the first string and minus one and we initialize the slash 0 at the string. Similarly str2 is we first calculate the length of the string 2 and then here we strln of string 2 minus 1 then here this str2 is assigned the slash 0. If both the strings are same then we display this message on the screen that both the strings are anagram. So here %s and %s means this %s value stored in the str1 and this %s value stored in the str2. If the check anagram function is called and if str1 and str2 two strings are passed and if it is not the same means it is not equal to one then here the else part is executed and similarly here we are then calculate the length by using strln function and we initialize the slash 0 to the string. Then str2 similarly and we display the message on the screen if %s and %s are not anagram and that %s value stored in the str1 and that %s value stored in this str2. So here we use the if l statement for displaying whether the given string is anagram or not. Next we see the actual anagram function so we know that the written type of this function is integer the name of the function is check anagram it takes a two parameter of types character so character pointer str1 character pointer str2. So here we take the two character array str1 and str2 character store. So here we initialize the value to 0. Next we keep the one counter value then here we check the length of the equality of the two strings. So two strings having the same length or not that's why here we use this strln function. So here we use the if strln of string 1 if it is not equal to string 2 then we return the value 0. So two strings having the same length or not that's why here we use this strln function. So here we use the if if strln of string 1 if it is not equal to string 2 then we return the value 0 that we use the for loop for counting the frequency of characters in string 1. So here we initialize the counter value to 0 that counter is initialized till the str1 of counter is not equal to slasero. We know that the string is entered by the slasero character so till the loop is continued till we not getting the value slasero and after that we increment the counter. So here what we see here we use the one character array. So str2 character of character. So here we check character of character we store the in character array. So str1 of counter if it is there then we increment the value of that counter variable means what? Here we checking the frequency of each and every character in str1. Similarly we count the frequency of character in str2. Again we use the for loop and that for loop is starting from counter equal to 0 and that loop is entered till str2 of counter is not equal to slasero. Here we have used the second array and str2 of counter plus plus every time we calculate the frequency of the character. Then after counting the frequency we compare. Compare the character counts of both the string. Again we required the loop because it in the character array we store the character character by character. So for iterating every character we required the for loop and here again for loop starts from 0 till 256 character because our array size is 256 so that's why the loop is iterated from 256 character and then we check the counter we increment. Here we use the if character 1 of counter character counter of sit here is not equal to if it is not same character 2 of character counter to character then it return the value 0 to the one function. Otherwise it returns the value 1 to the main function. This is the function body of check anagram. See once again we see what is the logic here applied. So check anagram function here we declare the two character array for keeping the frequency or for counting the frequency of the two strings. So here first we check both the strings are having the same length or not. If the both strings are same then and then only we return the value 0. If the string length of str is not equal to str2 we return the value 0. Next we take the two for loops for counting the first for loop is for counting the frequency of counting the frequency of each character in str1 and the second for loop is required for counting the frequency of character in str2. After that we compare the character counts of both the string. If it is not equal we return the value 0. If it is equal we return the value 1. After that we compile the file. So click here build then we run the file. Enter the first string spare and peers. Spare and peers are anagram because here the peer string is nothing but it is another string but this string is formed by contain the same character but the order of the character is different. Now after seeing this program can you tell me if the length of the input string are not same then is it possible to check anagram of string? Pause the video and think about it. The answer is no. If it is not same then we cannot check the anagram of the two strings. These are the references. Thank you.