 Hello welcome to the session functions in C. The learning outcome at the end of this session the student will be able to implement a C program using the basic concepts of a function. A function is nothing but a block of code which is used to perform a specific task. A small task it may be average addition like this. It can be written in one program and used by another program without having to rewrite the piece of code ok. So we are using this program in different other program also they can call this program so that it promotes the usability. This can be put in the library if the program is called by another program ok so that it can be include in the appropriate header file in the beginning of the program and link to the correct library while compiling it. There are two types of the functions. Function can be divided into two categories that is one is standard function which are already in the C program and the user defined functions which are defined by the user as per their requirement. So in the standard function or predefined function or we can also say this is a library functions these are the functions they are predefined by C and put into the standard C library like printf, scanf, strcpo. Here when we need to use that we have to include that into the appropriate header files that is if we want to use printf and scanf then we can include stdio.h then some mathematical functions are there sine, cos and all this that time you can include max.h and when you are using like this strcpy or string compare strcmp type you have to include string.h. Now in this user function what will be there? In the user functions they are written by the programmer or user themselves to carry out the various individual tasks and that tasks are reusable and therefore the programmer can use the instead of rewriting that he can use the same code. Now for that we need to follow some rules that is create a function prototype that means you have to declare that function which you are going to create it. Then after that for the implementation you have to define that function somewhere in the program you can define it at the start or somewhere other place then call the function whenever it is needed in the program. Now how that function definition is there that is the just we have seen that part is the function definition. Now in this function definition is that actual code where we are writing which can be going to be used again and again. So this code will be determined that function what it is doing when it will be called. So there are also some parts in that particular function definition that is a function returns data type ok. After completing that function execution of that function it will return some data ok. So that data type we should know so that is the return value. Then what is the function name we have to give some name to the function then some list of the parameters which in the parenthesis ok. Then you are having the statements that is what are the additions if statements are there or whatever other average statements are there. So that will be called as a function body. Now we will see one example for this this is the example that is we are having function name is calculate and it is returning the integer type. And here we are having two parameters number one and number two and what we are doing in the function we are calculating the sum of number one and number two and then that sum we are going to return. So here first we do not know what is the sum so this is a locally we are using. So here we will declare integer sum. As I said that is the above code is function name with the calculate it is calculating number one and number two with the addition and we are returning that addition. Whatever the function calls are there in the main program they are of two types either you can call the function with the whatever the value we are working on or you can call with the address of that particular value. Now in this method it will be copy one of the copy of that variable value we are providing to the function and it will be passed to the function and any modification of that values will be passed inside the function and that will not be affect the actual value. But in this case that is called by reference in this method the reference we are giving the actual memory address where we are storing that values. So it will be approaching inside the memory and then if we are adding or modifying something in that values then it will be reflecting into the memory and here of course as we are showing memory location it will be affect the actual value and for this we need the knowledge of pointers and array to handling this call by reference. Now here we will see how the functions are actual having the prototype or a skeleton we can say this here. So this is the main program here we are having some two functions function one and function two. So arrow you can see this so it will be go to the start of that function whatever the function will do that will be calculations or manipulation will be done and then it will be return the value to the same place where the function one is there. I need some another function so here function two is called here again it will be go to the start of that function where it is declared defined and then whatever the inside the statements will run and after completion of that it will return the value and it will be reaching to the function two. Now here you can see this the same thing we are having here that is when we are having actual values here we are putting that scan number one and number two here we are using asking user to put the numbers number one and number two and then using that number one and number two we are calling here function that is calculation of sum then here actual my function calling has happened so it will move immediately it will move to the function here and here it will be having this values okay so this will be replace this value one and value two by number one num one and num two then it will go inside here we are having local variable that is int sum so it is declared and then sum is equal to whatever this value one and value two is there they will do the addition and that sum whatever the two plus three or whatever the number we have passed that will be phi u will be return here to this sum so this is the flow of the data how actually the data is flowing in now find out the answer for this what does the following function print for n is equal to 25 okay if I am having n is equal to 25 after running this function what output will be there so here void function integer n the n value is 25 here so I am calling this function with the 25 u number so n is not not zero then it will be going to print this value so what will be the output just stop the video and try to answer it there are four values it is given okay so this function is returning this value one zero zero one one okay so this is the function mainly prints the binary representation in the reverse order whatever the number is there the binary representation of that number is the 25 divided by 2 there will be one then you are having n by 2 that is 12 divided by 2 that will be 6 we are not having any remainder here again 6 divided by 2 that we do not have any remainder 3 then 3 divided by 2 we are having remainder 1 and 1 divided by 2 again it is remainder 1 so accordingly the value is there by this function it is a binary representation as I said that is in the reverse order thank you