 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. Before seeing the videos, students must watch the following videos on the functions. So here I will specify the links of every video. Now today in this session we will see a program to find the sum of the series 1 factorial divide by 1 plus 2 factorial divide by 2 plus 3 factorial divide by 3 plus 4 factorial divide by 4 plus 5 factorial divide by 5 using the function. First of all we see the concept. So here the series is 1 factorial divide by 1 plus 2 factorial divide by 2 plus 3 factorial divide by 3 plus 4 factorial divide by 4 plus 5 factorial divide by 5. So this is our series. So we know that 1 factorial is 1. So 1 divided by 1 it gives the answer 1 plus 2 factorial is nothing but 2, 2 divided by 2 is nothing but 1 plus 3 factorial is 6, 6 divided by 3. It gives the answer 2 plus 2 plus 4 factorial is nothing but 24, 24 divided by 4 is nothing but 6 plus 5 factorial is nothing but 120, 120 divided by 5 is nothing but 24. So after this we add this all these numbers. So here the sum of the series is 34. So we see this program on the code block. First we create the new project, file new project, here we give click on the console application, then click on the C language, then give the name to the project, click on the next button and then click on the finish. You can say that in the left hand side it creates the project and the name of this project is sum of series, here the main .c file is created. Here first of all we write the function declaration. So where we declare one function factorial for calculating the factorial. So here the written type of this factorial function is integer, the name of the function is fact and it takes one parameter of type integer. So here I will specify int and end with the semicolon. This is your, this is our function declaration. Here in the main function we declare the variable. So here we declare one variable sum for storing the sum. So here first of all we call the function sum equal to, because here the function fact is written in the value. So that is why the value is stored in the variable sum. So here we call the function fact of 1. So first we calculate the factorial of 1. It is divided by the 1 plus here we know that in the given problem segment, in the given problem segment we require the sum. So that is why here we add the plus symbol. Similarly we again call the function for the 2. It is divided by the again 2 plus fact of 3. Again we call the function factorial for calculating the factorial of 3. Again whatever the answer is there that is divided by the 3 plus factorial of 4. We call the function again it is divided by the 4 plus again we call the function for calculating the factorial of 5. Again it is divided by the 5 and it is end with the semicolon. After that we display the message on the screen. Print F the series our series is 1 factorial divided by 1 plus 2 factorial divided by 2 plus 3 factorial divided by 3 plus 4 factorial divided by 4 plus 5 factorial divided by 3 divided by 5. So we first of all showing the message on the screen and end with the semicolon and after that we display the message on the screen. Print F the sum of series is we use the format pacifier parsendi because sum is of type integer and we end with the semicolon. This is our main function after this we write down our function definition for the calculating the factorial. Here we write down the written type integer name of the function is factor fact here it takes one parameter of type integer ok the name of the variable is n ok here we write down the function body here we take the one variable num and we initially assign the value 0 to the num and for storing the factorial we use the F variable and it is initialized to the one value. Here we use the while loop here in the while loop we specify the condition the given number num is less than or equal to n minus 1 the loop will be iterating after that here we calculate the factorial and we add it. So here we added the number so whatever the number is there at a store in the F value so we are put F equal to F plus F into num value of the num and end with the semicolon and after that we increment the num value by 1 every time this we written the value that is storing in the F. So here we use the written function written for written the value it is stored in the F and that value is written to the function that value is written to the main function and that value is stored in the sum. So first of all we see the execution of this loop or this function so here initial the value of n is 1 so 1 and here the num is initialized to 0. So 0 is less than equal to here our value is n is nothing but 1 so 1 minus 1 means 0 is less than equal to 0 condition becomes true the control go inside the while loop. So here we initialize the F to the 1 so 1 plus 1 into num so 1 into num the value stored in the num variable is 0 so after multiplication the value becomes 0 0 plus 1 the value stored in the F is 1 after that we increment the num value num becomes 1. So here 1 is less than equal to 0 condition becomes false control come out of the loop and return the value of F to the calling function so it returns the value 1 to the this function. So here 1 divided by 1 it becomes 1 similarly here we call the function fact of 2 again function is called so here n value is 2 then initially num is 0 0 is less than or equal to 2 minus 1 means 1 F equal to F plus F into num so here F is 1 1 plus 1 into our num value is 0. So again F into num becomes 0 0 plus 1 F becomes 1 again num plus plus the num becomes 1 1 is less than equal to 1 yes here the equality conditions true then again control come out of come in the loop. So here the F value is 1 1 plus 1 into num so here num value is 1 so 1 into 1 plus 1 1 into 1 1 plus 1 answer is 2 the value stored in the F is 2 again num plus plus num value becomes 2 the given condition becomes false come control come out of the loop here the return function returning the value 2 to this function to F fact of 2 is nothing but 2 2 divided by 2 it returns the value 1. Similarly we call for the fact of 3. So when the function is called fact of 3 the control is come here similarly we call for the fact of 3. So fact of 3 the here the n value becomes 3 so initially the num value is 0 0 is less than equal to loop is continue till 2 F is F value stored in the 2 2 plus 2 into 0 so 2 plus 2 2 into 0 means 0 the value stored in the F is 2 then num plus plus so here num becomes 1 so 2 plus 2 into 1 so again 2 plus 2 means 4 the value of F becomes 4 again num becomes 2 to 2 plus 2 into 2 to 2 into 2 4 4 plus 2 6 so here F value becomes 6 num plus plus num becomes 3 control condition becomes false control come out of the loop F value is written 3 factorial is 6 and then we 366 divided by 3 it returns the value 2. Similarly we call for the fact of 4 and fact of 5 after we compile this file it shows 0 in a 0 1 is then we run the program the sum of the series is 34. Now after seeing this concept can you implement the code for displaying the sum of the following series pause the video and think about it here in this is we calculate the sum of 1 divided by 1 factorial plus 4 divided by 2 factorial plus 27 divided by 3 factorial this program we write the code here we calculate the factorial so here we may specify the fact function it takes the one parameter of type integer here we calculate here we declare one variable F and it is assigned the value 1 and here we use the I is initialized to n I is greater than equal to 1 I minus minus here we calculate the factorial so here we specify F equal to F into I after that we return the F to the calling function F fact now these are the references thank you.