A function in C language is declared as follows,
return_type function_name(formal parameter list)
{
Function_Body;
}Best answer
A function in C language is declared as follows,
return_type function_name(formal parameter list)
{
Function_Body;
}A function is declared with a prototype: return_type function_name(parameter_list);, ending with a semicolon and without a body.
For example:
#include <stdio.h>
int add(int a, int b); /* declaration (prototype) */
int main() {
printf("%d\n", add(3, 4)); /* function call */
return 0;
}
int add(int a, int b) { /* definition */
return a + b;
}int add(int, int); is also valid.If a function returns nothing, its return type is void; if it takes no arguments, write void in the parentheses, e.g. void display(void);.
Log in or create a free account to answer this question.