Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What are the two types of default parameters in C language

Shulou Source: shulou.com Published: 2022-05-31 10:55:49 09月30日 Update

This article mainly introduces "what are the two types of default parameters in c language". In daily operations, I believe that many people have doubts about what are the two types of default parameters in c language. The editor consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "what are the two types of default parameters in c language?" Next, please follow the editor to study!

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 value is 5 printf ("sub function calculation result =% d\ n", sub (a)); return 0;} / * output: sub function calculation result = 10sub function calculation result = 15 parameters / at this point, the study on "what are the two types of default parameters in c language" is over, I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Functions results parameters types languages formal parameters learning variables more help output utility and then only articles methods theories knowledge articles websites Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info NVidia Xiaomi MySQL Redmi