Calculation method of variable range in c language;
1. Use the return value of the function. Returns the variable calculated by a function as a return value to other functions.
2. Use the parameters of the function. If the function parameter is set to pass by reference instead of by value, the variable calculated by the function can be used by other functions through this parameter.
3. Use global variables. Save the value calculated by the function into a global variable, and other functions can also use it.
Extended data
The principle of automatic data type conversion in C language operation
1, implicit conversion
C language performs implicit conversion in the following four situations:
In the (1) arithmetic expression, a low type can be converted to a high type.
(2) In the assignment expression, the value of the right expression is automatically implicitly converted to the type of the left variable and assigned to it.
(3) When passing parameters in the function call, the system implicitly converts the real parameters into the types of formal parameters and assigns them to formal parameters.
(4) When the function has a return value, the system will implicitly convert the return expression type to the return value type and assign it to the calling function.
2. Implicit conversion of arithmetic operation
In arithmetic operations, the following types of conversion rules are first adopted:
(1) characters must be converted into integers first (C language stipulates that character type data and integer data can be common).
(2) short types are converted into int types (both of which belong to integer types).
(3) Floating-point data is always converted into double-precision data during operation to improve the operation accuracy (both are real numbers).
Secondly, there are the following rules.
When operating different types of data, you should first convert them into the same data type before operating. The switching rule is to switch from low level to high level.