What is the function declaration format in C language?

烟雨青岚
Release: 2020-06-30 17:04:24
Original
17748 people have browsed it

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.

What is the function declaration format in C language?

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();
}
Copy after login

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);
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template