 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. Students must watch the following videos on function before this video. Now today we see the problem statement on function. The problem statement is write a program in C to find some of all array elements by passing the array as an argument using user defined functions. So here we define the function for calculating the sum of array. So here we use the code block for creating the program. So here we open the code block, here we create the new project, click on the console, click on the C language, give the name to the project, then click on the next button and click on the finish. Here in the resource folder it creates the main.c file and open it. First here we declare the function. So the function is declared, first we write down the return type of that function, here the return type of the function is integer, the name of the function is sum of array. Here we pass the two parameter to the function, first is the array and second is the number of elements to the array. This is your function declaration. In main function first we declare the variables for taking the input. So here first we declare the variable n, here we declare the array of maximum size 50, after that we take one looping variable i and here we use one variable s, after that we display the message on the screen, enter number of elements for sum and that value is stored in the variable, after that we use the loop concept for taking the input from the user. So here we use the for loop that i will be starting from 0 till i less than n and after that we increment the value of i, here we display the message to the user, enter value, then that value is stored in the variable, that value is stored in the array variable. So here we use ampersand of r of i, after that we call the function, how we call the function? We call the function by writing the function name, here the name of the function is sum of array, here we pass the actual array and actual array and number of elements. Here our function is returning the value, so that is why here we store that value of function, so here we use the variable s, so here we write down s equal to sum of array, then we use in the printf statement for displaying the sum, sum of array on the screen and that value is stored in the sum, this is our main function, after that we write down the function body, here the name of the function is sum of array, it takes the two parameter integer array and it takes the number of elements for array, here for calculating the sum we use the sum variable and we required one variable, it is a loop variable, so here we use the for loop for i equal to 0, i is less than n0, here n0 value stores the number of elements and after that we increment the value of i, here we use statement sum equal to sum plus array values, that value is stored in the x of i, i is the subscript variable, after that in some variable it stores the sum of all the elements, that value is written to the function, so here we use the written statement, return sum and we close the function body, return statement, return the calculating sum to the function and that value is stored in the s and we display that value on the screen, next we compile the file, here the method displays enter the number of elements for sum, I want 5 elements, we take the input 10, 20, 30, 40 and 50, then it calculates the sum of array 150, after seeing the concept of how we pass the array elements to the user defined function, can you write a c code to find the length of the string by passing the character as a array as an argument to the function, pause the video and think about it, here the written type of the function is integer, the name of the function is string length and here we pass the character pointer array str, here we take one variable length, here we take for loop for returning the each and individual characters, so here length initialized to 0, str of length is not equal to null till that loop will be executed and the length will be plus plus, here we will return the length to the calling function, so here we use the written statement, similarly you can write the code to find the total amount of purchased items by passing the structure as an argument using user defined function, again pause the video and think about it, how we write the function, we take the calculation for price item, so here the name written type of the function is float, the name of the function is gate total amount, here we pass this structure variable, so here str item, item is the name of the structure and item is a structure variable, here we calculate the sum by using item dot total amount equal to item dot price into item quantity, this is your function body, after calculating total amount we return that value to the calling function, we see the program on the code block, enter string, for example here we pass the string val chain, then it displays the length at on the screen, so here in this program first we declare the string length function, here we pass the character pointer array, in the main function we declare the one character array, for taking the string here we declare one length for calculating the length, instead of after that we take the input from the user the actual string and that value is stored in the S variable, here we call the function string length and that here the length function is returning the value of integer type, so that is why that value is stored in the one variable length and we display on the screen the length, here the definition of the function is, this is a function body, here we take one variable length for calculating the length, that value is starting from 0 and we treat each and every character till we are not getting the slash 0, here in a string slash 0 indicates the end of the string and after that we return the length value to the calling function, so it displays the length of the string, now next we see the structure program, here first they are displayed the message enter item name, here we enter the name item name pane, price will 10, number of quantity 5, so after that it calculates and display the total price on the screen, also display the item name price and quantity, so for this program first we declare the structure, here we declare the three members for this structure, the name of the structure is item, first member is item name which is the character array because it is string, next we take the number of quantity that is why here it declare as integer and here we required the two variables of float type for calculating the price and for calculating the total amount, here we declare this function get total amount and here we pass actual structure as a parameter, in the main function first we create the structure variable, the syntax for creating the structure variable is struct, name of the structure is the item and it is the name of that structure variable, after that we take the input from the user, enter item name that value is stored in the item name, here we take the input for the user from the user price that value is stored in the price, after that we take the input from the user the quantity and that quantity is stored in the quantity variable, here we call the function, the name of the function is get total amount, here we pass the actual function variable that is your it and after that we display the name, price and quantity on the screen and we calculate the price and the calculated price, here the after calculating the price the value is stored in the t amount, so that is why here we specify the t amount, now we see the function definition or function body of the get total amount, here we pass create the passing actually the structure variable, so here stop item, item is the name of the structure variable, item dot total amount, total amount is a variable it is declared in the structure, item dot total amount, we know the how we access the structure element, we access the structure element by using structure name, item dot total amount equal to item dot price into we calculate the quantity and whatever the value is calculated is stored in the total amount and here we return to the calling function, now these are the references, thank you.