The c language function declaration format is "function type function name (parameter list);". In the parameter list in a function declaration, specific variable names do not need to be given, but the type of each variable must be given.
Function declaration, the format that is not a description is the first line of "Function Definition Format", and then add ";", that is:
Function type function name (parameter list);
Specifically, in the parameter list in the function declaration, the specific variable name does not need to be given, but the name of each variable must be given type.
#include<stdio.h> int getMax(int a, int b) { if (a > b) { return a; } else { return b; } } void main() { int t=getMax(12, 21); printf("%d\n", t); getchar(); }
Extended information:
We can understand the concept of function in this way. A function is a collection of functions. It can complete close-up functions based on input and convert the results output. Of course, sometimes functions are just to implement some close-up functions and do not necessarily have input or output.
If we want to write a function ourselves, we need to write two parts: declaration and definition. The declaration of a function tells the compiler that we want to define a function and clearly specify its return value (output), function name, and parameter list (input). The syntax for declaring a function is as follows:
type function_name(type var);
Recommended tutorial: "C Language"
The above is the detailed content of What is the function declaration format in C language?. For more information, please follow other related articles on the PHP Chinese website!