140829 ● Functions

Source: Internet
Author: User

Function

Advantages: 1. Code can be reused; 2. Code is relatively independent; 3. Easy division of labor

Programming: High Cohesion and low coupling

Function Definition and call. Example:

 1           //  Defines a maximum function.  2           Static   Int Max ( Int A, Int B) //  A and B are form parameters. function input 3   {  4               If (A> = B)  5   {  6                   Return A; //  If a> = B, the returned value is.  7   }  8               Else  9                  Return B; //  If a <B, the return value is B.  10   }  11   12           Static   Void Main ( String  [] Arge)  13   {  14               //  Call a function  15              Int A = 3 , B = 6 , C = 1 , D = 4  ;  16               Int Z = max (a, B), c), d ); //  A, B, C, and D are real parameters (actual parameters)  17   Console. writeline (z );  18   19 }

 

The running result is as follows:

 

140829 ● Functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.