Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the two types of default parameters in C language

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report