#include <stdio.h>
int addNumbers(int a, int b); // function prototype
/*
The Function prototype serves the following purposes –
1) It tells the return type of the data that the function will return.
2) It tells the number of arguments passed to the function.
3) It tells the data types of each of the passed arguments.
4) Also it tells the order in which the arguments are passed to the function.
Therefore essentially, the function prototype specifies the input/output
interlace to the function i.e. what to give to the function and what to expect
from the function.
The prototype of a function is also called the signature of the function.
*/
int main()
{
int n1,n2,sum;
printf("Enters two numbers: ");
scanf("%d %d",&n1,&n2);
sum = addNumbers(n1, n2); // function call
printf("sum = %d",sum);
return 0;
}
int addNumbers(int a, int b) // function definition we can call
{ //it here or on top after fun declaration
int result;
result = a+b;
return result; // return statement
}
#if 0
#include <stdio.h>
int myFunction(int x, int y) {
return x + y;
}
/*
* Function Definition before main
* In this case function declaration is not required
*/
int main() {
int result = myFunction(5, 3);
printf("Result is = %d", result);
return 0;
}
#endif
To embed this program on your website, copy the following code and paste it into your website's HTML: