 Hello 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. Before watching this video, student must watch the following videos on the functions. In this session, we will see the problem statement. The problem statement is write a program in C to check whether a number can be expressed as sum of two prime numbers. So here we have to check whatever the given number is there, if we can express as a sum of two prime numbers. So here we will see the one example. So here the number is 16, the sum of that 16 number is what, 1 plus 15, so sum is 16. But here we have to check whether that 1 and 50 can be expressed as prime numbers. So here the 1 and 15 both are not prime numbers. So here we cannot express as a sum of two prime numbers. Now in the next you can see here 2 plus 14. So here the sum is 16, but here the 2 is prime number, but 14 is not a prime number. So here we cannot express as a sum of two prime numbers. Because here 14 is not a prime number. Now in the next here we can see the sum of two numbers is 3 and 13. The sum is 16, here both are the prime numbers. So here we can express as a sum of two prime numbers 3 and 13. Now in the next 4 plus 12 the sum is 16, but here 4 and 12 both are not a prime numbers. Now in the next the numbers are 5 and 11. So here the sum is 16, both 5 and 11 both are the prime numbers. So here we can express these numbers as a sum of two prime numbers. Now in the next 6 plus 10 the sum is 16, but here the 6 and 10 both are not a prime numbers. Now in the next the numbers are 7 and 9. The sum is 16, but here 7 is the prime number, but the 9 is not a prime number. So here the problem statement is we have to check the given number can be expressed as the sum of two prime numbers. So here we taken the example as number 16. So here the number 16 can be expressed as the sum of two numbers, two prime numbers for the numbers 3 and 13 and 5 and 11. Now next we see this program on the code block. So here first of all we have to write down this program using function. So here first of all we include the header phi, hash include stdio.h. Now next here we declare one function, the name of the function is the check prime and the return type of that function is the integer. The check prime function takes one parameter of type integer. So here we specify here int n. So this is the declaration of the function. Now next here we specify the main function. In the main function we declare the variables. So here the variables are of type integer. So here we require the three variables n, i and flag variables and all these are the type of integer. So here the flag variable is initialized with the value 0. Now next we use the printf statement. Printf statement it is used to display the message on the screen. So here we specify the message on the screen enter a positive integer. Means what? Phi we specify this message which number we have to specify as a sum of two prime numbers. That number we for that purpose here we specify the printf statement. In the printf statement we specify enter message enter a positive integer. Now that value is taken in the variable n by using the scanf function. Now the next statement is the scanf. Here we specify the format specify. Here the n variable is of type integer. So that is why here we specify the format specify %d and next we specify ampersand n. So here the value of that integer we stored in the variable n. Now next we use the, here we use the for loop. In the for loop we specify the iteration value i equal to 2. Here i variable is initialized to the 2. The condition is the loop is iterated till i is less than or equal to n divided by 2. And here the i value is incremented by 1. In the for loop we use the if statement. Here in the if statement we specify the check prime. Here we call the check prime function. Check prime and here we specify the value of that i variable. When this check prime value is returning the value 1 then and then only the next if statement will be executed. So here the next statement is the if check prime of n minus i. If it is equal to equal to 1 then we display the message on the screen that value is specified as the sum of 2 prime numbers and here we set the flag variable to the 1. So this if statement it is used for checking the number that is n minus i to be the prime numbers. So that is why here we specify the if statement. Now here we close the if statement and then next here we close the outer if statement and then we close the for loop. Now after that here we use again the if statement. Here we check if flag value equal to equal to 0 then we specify on the screen the message that percent the value cannot be expressed as a sum of 2 prime numbers and that value is stored in the n variable. So this is the code of the main function. Now next we see the code of the check prime function. So here the written type of the check prime function is integer. The name of the function is the check prime it takes the integer type value. Now here we use the here we declare the variables of type integer here we declare two variables i and is prime. So here is prime again it is used as a flag variable and here we initialize the value 1. Now here again we use the for loop for iterating the values. So here the i variable is initialized to the 2. And the condition is what i is less than or equal to n divided by 2 and here i variable is incrementing by 1. Here in the for loop we check the number is prime or not. So here in the if statement we specify n mod i if it is a equal to equal to 0 then in that means or that number is the factors. If it is a factors then here we check if n mod i equal to equal to 0 then here we specify the values 0 to the is prime variable and then we break that loop and come out of that loop. And after that after closing the for loop here we return the is prime value to the calling function. So here the calling function is the main function. So here that value is returning to the calling function main function. Now next we compile this program. Now next we run this program. So here in the screen this display the message enter a positive integer. So here we specify the number 4. So here the number 4 can be expressed as a sum of 2 prime numbers. So here the sum of 2 prime numbers are 2 and 2. So the sum is 4. So how this will be executed see here the n value is the 4. So first of all this printer statement will be executed. So here we enter the value 4 that value is stored in the n variable. Now next this for loop is executed for i equal to 2 i is less than equal to n divided by 2. So that next will be what here we enter in the for loop if check prime of i equal to equal to 1. So here the i value is what? Here i value is 2. So here the check prime of 2 the function is called. Now here the control is passed to the check prime function. So here the value is stored is 2. Now here first of all this for loop is executed i equal to 2 i is less than equal to n. So here the value of n is 2. So 2 divided by 2 the value is 1 and the i value is 2. 2 is less than equal to 1 the condition becomes false and here we are returning the value of each prime. So here the each prime value is 1. So here the value 1 is returning to the calling function means what here the main function. So here the check prime function running the value 1. So here in the if statement we check 1 equal to 1 yes the condition becomes true. Now the control is come inside the if statement again the here we called the check prime function for checking the n minus i value if it is a prime number. So again the check prime of n minus i. So here the n is what 4 and i is what 2 again the value is 2. So for that check prime function is called check prime of 2 again the function is called the control is passed to this check prime. Again this for loop is executed i equal to 2 i is less than equal to 2 divided by 2. Again the value the condition becomes false this loop is not executed again this return statement is executed and here we return this 1 value to the calling function. So here the 1 value is returning to the calling function and here we check 1 the check prime of whatever the value is returning so here the value is returning 1. So 1 equal to equal to 1 yes the condition becomes true. Now next the printf statement is executed percenty equal to percenty plus percenty. So here the first percenty value is n so here our n value is 4 equal to percenty plus percenty means what i and n minus i. So our i value is 2 so that is why here they specify the 2 value and n minus i also the value 2 so that is why here they specify the value 2. Now next here our flag variable is set to the value 1 and then we come out of the for loop. So again we run this program so in this way the program is executed here we specify the next number 16. So here the 16 number is specify the sum of 2 prime numbers 3 and 13 the sum is 16 and both are the prime numbers. Now next here 5 plus 11 both are the prime numbers and we specify as a sum of 2 prime numbers. After seeing this concept can you write a c code to check the prime numbers in an array pause this video and think about it. So here we have to check the prime numbers in an array. So this is the function so the written type of the function is the integer the name of the function is the it's prime it takes the of one parameter that is a num of type integer. Now here one we declare one integer type variable. Now here we use the for loop the for loop will started i equal to 2 i is less than num divided by 2 and after that i variable is incremented by 1. So here in the for loop we check if num mod by i equal to equal to 0 if it is equal to equal to 0 then here we set the flag variable to the 1 and then we break this loop and come out of the loop. And next after that we after calculating the factors of that numbers then here we check if the flag variable is equal to equal to 1 then here we are returning the value 0 to the calling function otherwise we are returning the value 1 to the calling function. So this is the function for checking the prime numbers in an array. These are the references thank you.