Hello, today we will learn about function in c programming...............
Function:
Function is self content block of code that performs a particular task. Most of the computer programs that solves much bigger and complex. Every C program can be thought as a collection of these functions. They interact with each other to accomplish a particular task function follows following approach. This approach of problem solving is called as conquer and divide strategy.
Types of function:
- Function prototype /declaration
- Function definition
- Function call
Function prototype:
Syntax:
return type function name (parameter list)
Ex.
int sum (int a, int b)
float mul (int, float, int)
Function prototype consist of three part-
- return type
- type of parameter
- no. of parameter
Function call:
Function call by simply using function name following by a list of parameter.
Syntax:
function name (parameter list)
Function definition:
Function prototype consist of two parts functions header and function body.
return type function name (datatype para1, ........,datatype para n)
{
body of function
}
First of all as I say that there are three part of function mean we have to follow three time rule mean first after include the header file we have to create a function in this.
In function prototype according to syntax we write return type then after we give name to that function and then we write variable name as parameter list in ( ) this bracket .
We use function call when we need any time that function in our program,
then we reach at function definition every important work is done here mean programming , this is also use as main function , we take input in main function and calculate in function definition then by return keyword we pass this to main function
Thank you,
if any related problem this post please comment below.
keep supporting....................
Comments
Post a Comment