15th talking about Functions
Function: Given the value of the independent variable, you can get the function value.
ProgramFunctions in design:
Function;
Parameters;
Return value;
All meaningful functions have functions;
A function is a function module;
Writing a function actually isolates a function module.
1. Max is the maximum value.
2. Calculate the area with the given radius of cirarea
Max must have two parameters: num1 and num2. return values: the maximum value.
Cirarea must have the parameter r returned value: Area
Function call
Use Functions
Code:
Public partial class form1: FORM {
Public form1 (){
Initializecomponent ();
}
// The load time processing function of the Main Window cannot be called only by the operating system.
Private void form1_load (Object sender, eventargs e ){
/*
Int A = 13;
Int B = 14;
Int y = max (A, B );
This. textbox1.text = Y. tostring ();
//*/
/*
Int r = 13;
Float area = cirarea (R );
This. textbox1.text = area. tostring ();
//*/
}
// The function of the Max function is: a large number of outputs.
Private int max (INT num1, int num2 ){
If (num1> = num2 ){
Return num1;
}
Else {
Return num2;
}
}
// Calculate the area of the circle
Private float cirarea (int r ){
Const float Pi = 3.14f;
Float area = 0;
Area = pI * r * R;
Return area;
}