 Today we are going to see return statement and passing the parameter to the function. Learning outcome at the end of this session students will be able to write a C program using function with parameters and return value. Now first we see the return statement. Return statement is used to return a value to the calling function. It can be used to terminate the execution of function and returns the control to the calling function. When return is encountered in the program the execution resumes in the calling function at the point immediately following the function call. Now let us see diagrammatically how the calling function and call functions are used. Here we see three blocks, here main function, function 1 and function 2. Here the main function is the calling function and function 1 and function 2 are the called function. In main function we called the function 1 and function 2. When the function 1 is called the control passes to the function 1 and now this is the first statement. After that control passes to the function 1 the statements inside the functions are executed and when the return statement is encountered the control returns back to the calling function. Now this is the step 2. Again in the main function we call the function 2 then again the control is passed to the function 2. When the control reaches to the function 2 the statement inside the functions are executed and when the return statement is encountered the control again returns back to the calling function. Here our calling function is the main function. Now this is the step 2. Now next we see the syntax for return statement. There are two ways for how we declare the return statement in a program. First way is the simple return statement and the second way is the return with some expressions. Now first we see the simple return statement. It does not return any value to the calling function. When return encountered in the program the control is immediately passed to the calling function and it is basically used to terminate the function without returning a value. Now this is the first form of the return. The second form of the return statement is the return with some expression. It is used to terminate a function and return a value to the calling function. It returns value of the expression when a value is returned it is automatically passed to the function type. If the function type is void then it cannot return any value to the calling function. Now we see some examples of return statement. Now consider the function for multiplication of two numbers. Here the return type is integer. Function name is mul and here it takes the two parameters of type integer. In function body we first declare one variable of type integer for storing the result. Next we calculate the multiplication of two numbers and that value is stored in the p. Next this function is returning the value to the calling function. So here we use the return statement return p. It returns the value of the p which is the product of the value of x and y to the calling function. Instead of writing the two statements we can write only a single statement return x into y. Now next we see the another example of return statement. Return statement may return more than one value means function may have written more than one value. This situation occurred when the value returned is based on certain situation. Now consider this example. In this example we use the if-else statement. In if statement we specify some condition. If x then are equal to zero if it is less than zero then return the value zero otherwise return the value one. Now after that after seeing the return statement can you state whether a function can return only one value at a time, pause this video and think about it. A function can return only one value at a time. This statement is true. Now next we see the program to find the largest number using return statement. Here first we include the essential header file. After that we declare the function for the largest number. Here return type of that function is integer. Name of the function is larger and it takes the two parameters of type integer a and b. After that we declare the main function. In main function we create the three variables. We declare the three variables i, j, k, i and j for taking the two numbers from the user. So here we use the scanf statement for taking the input from user. After that we call the function larger and here we actual pass the value of i and j to the formal parameters a and b. So here i value is copied into the variable a and j value is copied into the variable b. Then control is passed to the function body. In function body we write the code for calculating the largest number. Here we use the if-else statement, here we specify the condition if a is greater than b. If the value of a greater than b then return the statement a, otherwise returns the statement b. According to your values the value is returned to the calling function and that value is stored in the k variable and we print that value using printf statement on the screen. And we close the function main. Next we see the passing the parameters to the function. Passing the function passes some value to the call function. There are two ways in which arguments or parameters can be passed to the call function, call by value and call by reference. In call by value we pass the actual value to the function and in call by reference we pass the address of that variable to the function. Suppose if we consider one example of addition we add the two numbers or we pass the value to the function. If we pass the value by calling by call by value then we directly specify the actual value and if we by using or we pass the parameter using call by reference then we pass the actual address of that variable. Now first we see the call by value. In call by value the values of the variables are passed by the calling function to the call function. If any value of the parameter in the call function has to be modified the change will be reflected only in the call function. This happens as all the changes are made on the copy of the variables and not on the actual ones. Now here we see the example how the call by value will be working. Here we first include the header file after that we declare one function sum and the written type of that function is void. It takes the one parameter n of type integer. In main function we create one local variable a and we assign the value to that variable 5 and after that we display the message the value of a before calling function and we display that value on the screen. After that we call the function sum and here we pass the actual value of a and in a that in a we store the value 5. Again we display the message the value of a after the calling function. When the function is called the control goes to that function body and that a value is copied into that formal parameter. In function body we just add the two numbers add the numbers n plus 20. Here n value is 5 because the value of a is 5 and that 5 is copied into the formal parameters n. So n plus 20 means 5 plus 20 it store in then 25 value stored in the n and we display the message value of n is called function is n and that n displays the value 25 on the screen. So before execution of the function main value in main function a value stores the 5 value and when the after the execution of function a value stores the 5 but whatever the changes done inside the formal parameters n that is not reflected to the actual parameters. So here in the a value again the 5 value is stored not the 25. Suppose in the previous sum program if we use the return statement to return the value of n to the main function then what would be the output? Pause this video and think about it. If we use the return statement in the sum program then the return type must be changed here return type is the integer. In the main function we create variable a and we assign the value 5 then here the function is written in the value. So that value must be caught must be stored in the variable a. After that we display that value on the screen. Then the control is transferred to the function body and here we calculate the sum and we store that into the n and here we use the return statement. Then when the return statement is encountered the control is passed to the calling function and it stores the value calculated in the variable a and it shows the output. Now these are the references. Thank you.