Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - If the return value type of the custom function is not written, does it return int by default? Does fun(int x) return int? Do I have to write the parameter type int?
If the return value type of the custom function is not written, does it return int by default? Does fun(int x) return int? Do I have to write the parameter type int?
(1) If the return value type is not written, the int type -correct will be returned by default.

Fun(int x) returns an int-correct.

(2) 2) Do you have to write the fun (int x) parameter type int?

Answer: It is related to the compiler. MS VC++ 6.0 can be omitted, and the default is int type.

For example:

# include & ltstdio.h & gt

fun(x){ return x * x; }

main(){

int y = 3;

printf("%d ",fun(y));

}

Output 9

-

Old-fashioned programs, parameter types are declared after parentheses, and types are not written in parentheses:

# include & ltstdio.h & gt

Floating fun (x)

Floating x;

{ return x * x}

main(){

float y = 3;

printf("%f ",fun(y));

}

-

(3) Function prototype declaration can only write types, not parameters, such as:

float fun(int,int);

-

(4) It is suggested to write the return type, parameter type and parameter name correctly.