Function definition in C

Hello coders! Welcome back!

Today will look into a function definition in more detail.

What is a function definition? 

A function definition consists of a set of instruction which is cable of doing some task. 
let's look into the example- 

We have seen in the previous blog, that how functions work. 
(click here to read the previous blog, to know how functions work) 

What is the difference between an argument and a parameter?

A parameter is a variable in the declaration and definition of the function. 
Argument is the actual values of the parameter that gets passed to the function. 

Let's look with the help of an code for better understanding. 

Observe line no.7 this is how we call a function. 
Note → While calling a function you should not mention the return data type of the function. And you should not mention the data type of arguments. 

Observe line no. 12 this is function definition. 
Note → It's mandatory to mention the return data type of the function and data type of the parameters. 

Parameters are also known as a formal parameter.
Arguments are also known as the actual parameter.

Actual parameters 3 and 4 are passed to the formal parameter. 
Now the base is having value 3 and height is having value 4. 
In the function definition, we calculate the area, which is stored in the 'c' variable.
Then we return the 'c ' value to line 7 that is 'a' variable. 
Then we finally print the value. 

This is it for this blog. Will look into functions in more details in an upcoming blog. If any doubts drop a comment always ready to help. 

Happy learning! 

Comments

Popular post