Hello everyone my name is (name) and we are continuing with this C programming course, in which we had discussed in the last video loop related statements, which means our break statement, continued statement and go to statement.
We saw all these three, understood them and we also got to know that all three had different functionality than each other.
In this video we are going to see what these functions are.
So, how is it to work with functions in C programming? This is going to be the topic of today's video and this will be basically covered in three parts.
This video is the first part in which we will see what these functions are and after that we will get to know what is the flow of the function, in the program which all would be the parts of the functions, which we have to learn and understand.
All these things we will see in this part one video, in the coming videos we will also see using them practically.
So, without any delay we will start and understand what exactly is a function.
If we talk about the definition, the definition says, “a function is a set of statements that take inputs, do some specific computation and produce the output.”
This is a basic definition in which it is trying to say that what a function is, function is a set of statements which basically takes some input and processes it, calculates it and provides one output.
So, basically this is the function’s work.
And the way to write it, is somewhat of this type, we had discussed even in the last video when in front of a name you see two round brackets.
That basically will be the name of a function and in front of it there will also be a data type which is at this time, in this example is an integer.
So, you can see that Num one is basically the function’s name.
And I N T is a data type of that particular function.
Why do we use it? And how is this function used for all these things we would see in the coming slides and understand it.
We can see a few examples of this function here, like there is a main function, like we all know the main door of the program is called as the main function and this is written as an example in the main function.
Apart from that there is sum, swap.
So, there are different types of functions with different functionalities, some are already made in the C programming, which we use as it is and few we have to make by ourselves.
So, all these things we will be discussing.
We will go ahead and see what is the flow of the function.
What are the different parts of the function, like if we have to make some function, what would be the way to make it and where we will use it and how the compiler will know that we have made one function, which we are going to use in our program? All these questions will be cleared from this particular slide and to understand this we will take one basic example: suppose, I have to give my home address to a certain person.
In this basically there would be three parts.
The first thing would be the person who is asking us for the address.
He will first of all ask for the address from us.
So, this we can call as the function call. right?
When he's asking for it only then we will give the address.
So, what we did on one paper was write the directions to reach our address, to go there one will have to turn left or turning right after 100 metres and then go ahead one kilometre after turning left and then take a right.
Whatever were the directions to reach that particular address.
All those I have written on one paper and gave it to that particular person.
So, this was a way to tell the address to the person who is asking for it.
We will understand it in the form of function, how the function is basically working in it.
We saw that the person who asked for the address, he called, he said will you be able to give your home address to me.
So, this is one call.
We call this a function call.
With which we get to know that you have to use the function now.
What does this mean? The person who asked for the address, he basically wanted to reach our home.
That is the reason why he asked for the address.
He had some particular work for that reason he called us for the address.
So, we can understand that this is a type of function call.
We will see them practically in the coming slides.
But for now, we can understand calls in this way.
So, this is about the call.
The second thing comes about writing the address or the directions on one paper.
So, what I did was, I know the address of my house but what I did is I wrote my address with the directions on one paper, okay?
So, what will this be? This will be my function definition.
So, this paper on which my entire address and direction is written, we will understand it as a function and all the things that we wrote inside this function, which means we have to take a left or a right or have to go straight, after 100 metres we have to take a left.
All these directions that were there.
This will basically be our function’s definition.
Are you understanding so far?
So, the person called, he called the function and we defined our function, we defined the function, we have to go left, right or straight and after taking the right from ahead, you will find my house.
This is what we have defined.
Apart from this, the declaration part which comes, how will we understand that.
Now the function that we have made, which we have defined, that everything should be in this way, the process.
We have made the process but how will we be telling this to our compiler? So, we tell this to our compiler by writing a statement and we call that our function declaration.
So, the compiler will get to know early on that we are going to use such a function which we have defined in our program.
So to tell the compiler we will make use of function declaration, we write a statement on our program, through which our compiler gets to know that the function of this name is made by our user or our programmer.
And going ahead it would be used in our program.
So, this example of providing the address, with this example we got to know what would be the function definition.
Function definition would be all the directions written on the paper.
What would be function calls? Any person who had to go home, that would be the call basically, he asked for our address.
So, we will call this call as a function call.
So, in one place I have written about my function that in this function these would be the statements, these kinds of variables will be made.
So, this is one part of the function definition.
In my program I will write somewhere the function name through which my compiler will get to know that you have called my function here.
So, here I'm calling.
As soon as I call the definition inside the function it will reach the compiler.
The compiler will get to know that basically with this function what are you trying to do? So, this was the story of parts of functions which are our definition, call and declaration.
We understood all three parts theoretically.
And we saw how we use an example, how we can differentiate these functions in different parts.
If you have any queries or comments, click the discussion button below the video and post there. This way, you will be able to connect to fellow learners and discuss the course. Also, Our Team will try to solve your query.
In the coming video, which means the part two of this particular video, we'll be discussing all these three things individually.
And we will see which is the way of writing this function definition.
Then we will see how we can call the function and then we will see whether the function declaration is compulsory or not and what is the way to write it? Till that time, thank you so much.
Share a personalized message with your friends.