Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Call of c language function
Call of c language function
1.# include & ltstdio.h & gt

2.int maximum (int x, int y, int z);

Main river

4.main()

5.{ int i,j,k;

6.printf("i,j,k=? \ n ");

7. scanf ("%4d% 4d",&me&&; k);

8.maxmum(i,j,k);

9.getch();

10. Returns 0;

1 1.}

12.maxmum (int x,int y,int z)

13.{

14 . int max;

15 . max = x & gt; y? x:y; (; Is a semicolon, preceded by a colon)

16 . max = max & lt; z? max:z;

17. printf ("the maximum value of three data is %d\n", max);

18.}

According to each line:

1。 Here is the included header file, which contains some functions you use. For example, if you use the printf () function, this function is not defined in this program, so how do you know it in this program? This is the header file. The function is defined in the header file.

2。 The following is a statement of the function prototype, which can be written as int maxmum(int, int, int). Because the prototype is declared, there is no need to define formal parameters in the declaration. Of course, your definition is also correct.

3。 This is the main function. Int main () conforms to the C standard and specifies the return value type of the main () function. Some people just write main (), but they don't meet the C standard. Generally, I am like this: int main(void) means that the main () function has no parameters and the return value type is int.

4。 I think you repeated this line. This line should be replaced by the third line. Take this off.

5。 Three integer variables are defined here.

6。 Printf output function is used for printing format.

7。 Scanf () is used to format the flower input. You need to spend some time figuring out this function.

8。 The maxmun () function is called here. Remember the statement of this function in line 2? Because you declared it, the main () function knew this guy when it was called here. You can use it. Otherwise it won't know, and the compilation process will go wrong.

9。 This is a function that gets input from the keyboard. In fact, its role here is to pause. You just need to enter a character and execute return 0 immediately. The program will be executed. Otherwise, the execution process of the program will flash by. You will know that this usage has security risks. How do you need further research to understand)

10。 Returning 0 here means that the main () function has been executed and returned successfully.

1 1。 This curly brace indicates the end of the mian () function body.

12。 The following is the definition of the maxmum () function. The following pair of curly braces is the code area of what function maxmum () can realize.

13. The beginning of a pair of curly braces

14。 Define an integer variable to store the largest number.

15. The following is an if conditional expression. That is to say, x is greater than y? Judge whether this condition holds. If true, assign the following x to max. If it is not true, assign y after the x colon to max.

16。 Analysis similar to 15.

17。 Maximum print format

18。 End of maxmum () function code segment.

If you need to call your own function, you must declare the prototype of the sum function before the call location. In other words, tell the compiler that you know this function, but what it does. I have a definition later, don't worry. Then the compiler will pass the compilation smoothly.

I'm tired of talking so much, I hope you can be satisfied!