Introduction of default parameters of function in C language
This article mainly explains "the introduction of the default parameters of the function in c language". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "the introduction of the default parameters of functions in c language".
1, all the default parameters of the function, when the function is defined or declared, all parameters are default.
# include / / XQuery y is the formal parameter of the function. If the function is called without setting x and y values, the x value defaults to 100, and the x value defaults to 5int sub (int x, 100) int Yee 5) {return (x Met y);} int main (void) {int adept 20; int baud 10; / / variables an and b are the arguments printf of the sub function ("sub function calculation result =% d\ n", sub (a, b)) / / Note: we have not set arguments for the sub function, so the default is "sub function =% d\ n", sub (); return 0;} / * output: sub function calculation result = 10sub function calculation result = 95 parameters /
2, the function semi-default parameters, when the function is defined or declared, only part of the formal parameters have default values.
# include / / XQuery y is the formal parameter of the function. If the y value is not set when the function is called, the y value defaults to 5 int sub (int Xreint yellow5) {return (XMY);} int main (void) {int aquifers 20; int banners 10; / / variables an and b are the arguments printf of the sub function ("sub function calculation result =% d\ n", sub (a, b)) / / Note: we did not set the argument for the second parameter of the sub function. At this time, the default is yroom5 printf ("sub function calculation result =% d\ n", sub (a)); return 0;} / * output: sub function calculation result = 10sub function calculation result = 15 arguments / so far, I believe you have a deeper understanding of the "introduction of function default parameters in c language". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!