OK this is a sample program using functions.
OK so two things you need to remember about adding a function.
OK.
First of all the function prototype.
OK so whatever you're going to define inside the program.
First you need to write the function prototype.
So it is the basic syntax.
OK.
So you have to write down the type and a functioning deliver parentheses and the parameter which you're
going to use in the function.
OK.
This is their function prototype actually.
Just to remind you this is something it actually is a good practice to write it.
But if you even if you don't write this function for the C program will get compiler model built on
it.
OK but it's a good practice to write the function prototype before defining it.
OK.
So here what I'm going to do is like once I have done the function prototype declaration with the function
which I'm going to use in the program we will jump into the definition.
OK here I am writing a very simple program.
So the function of this sorry the name of this function is addition.
OK.
Which I have one very record result of it the integer.
So I'm just printing this one.
OK.
I mean say the function addition OK you know what I'm doing is I'm just whatever the parameter I'm getting
this year.
So the two parameters which will be received have been this function is getting caught.
OK.
So I'm just adding this one which means for example if I'm getting 10 and then
then I should do that I should do it 30.
OK.
So for example if I may get funding 10 20 if I'm going then to be which Winston is a 20 is B then the
output will be 30.
So the output the 30 will be captured here and are reprinted here then the same I will return it to
the place where it's getting caught.
OK.
So I have one more function call subject same thing similar to edition and just subtracting here.
OK.
Again this value will be captured here are printed here and I'm just returning this value to the place
where it is getting caught.
OK.
So now we jump into the main function.
OK.
So a function for the type we have already discussed.
Function definition we have already discussed.
Now we'll see from there is getting caught.
OK.
So I have a I have 40 variables here plus some sub in to anyone.
OK.
So here's what I'm doing here is I'm just getting two parameters from the user.
OK.
And I will call the addition function and store the.
I'll just call this addition function and print the output here and I'll call again the subtraction
function and print output here is very simple.
OK.
So let's execute this and see what happens
OK.
Data is an error here.
Let's see what it is.
OK.
This one in a moment.
Company OK fine.
So as I told you earlier the program for execution really starts from main function.
So all the sub function whatever it is it's good will get called for that 100 functions also.
Here you can get caught for from main function.
OK.
So now I'm inputting the value as the first value then which is the N1 value.
Again I'm inputting the second value as an example 30 OK so what happened here is I'm OK.
It kept it captured the first real you hear it to capture the second value.
Then it called dysfunction court addiction.
OK so then the control vent here a controlled vent here OK so now it's telling that I'm inside the function
addition I'm inside the function audition.
So I had given 10 plus 30 so the output is 40 40 stored here.
Then the 40s printer here.
So this old value addition function is 40.
So this is printed here.
And this is a good contract on here.
So what is it written this some value.
This some variable will hold a value of 40 so this one here is printed here.
OK.
So if you see here I made the main function I main function function now some equal to 40.
OK.
So again it comes through subtraction function now.
And it made a call.
This is a function call to some production function.
So let's see we go here.
Is he here.
No I'm inside the functions of production.
So which the control is here.
No.
So it is valued suppression function it's minus 20 which means I input an Eastern on the basis that
these are 10 minus 30.
The output is minus 20.
So that's what is printed here.
It printed here.
This l value the suppression function is minus 20.
Again this value was returned the center this concept was returned to this function called function.
Now this value is minus 20.
So that's what is printed here.
I mean function and just a function.
No no this value has been restored.
OK so actually this is two times I mentioned here I've just remembered this printing closing this again
and let me try with another value.
I'm just giving 20 and then finally.
OK.
So what happens here.
Again the first value it got it captured here and then second value captured here then is getting addition
function.
So 20 plus for days the value sixty.
So there's still value at function.
In addition function 60 which means this one the third value addition function is 60 which is this one.
Then again this value got returned to the sum function.
So an imprinting the value here.
I mean the main function I mean functional this value sixty.
OK after this.
Again the subtraction function is called with two parameters which is the N1 is certainty and subtraction.
And the second n2 is 40.
So people come here OK inside the function some production which means here.
Then it's just subtracting here which means don t minus 40 is minus 20.
So it isn't value subtraction function in this result except so which is minus 20.
Again I'm returning this value to the main function to the main function which means no sub will have
minus 20 value nobody the return value from subtraction function.
So again I'm printing this value just minus 20.
So this how the functions it works and C programming language.
And thanks for watching this video.
We'll catch up in the next section.
Bye for now.