3.13-Function 2

Source: Internet
Author: User

#include <stdio.h>

/*

Parameter Note points

1. Formal parameters: A parameter that is followed by a function name when defining a function, for short, a formal parameter

2. Actual parameters: Call the function of the specific data passed in, referred to as an argument

3. The number of arguments must be equal to the number of formal parameters

4. Variables within the function body that cannot be defined as parameters

5. If the base data type is a function parameter, it is purely a value pass, modifying the value of a function's internal parameter without affecting the value of the outer argument

6. A function can have no formal parameters, or can have an infinite number of parameters

*/


Formal parameters, referred to as formal parameter

int sum (int num1,int num2)

{

The function body cannot define the same variables as the parameters

int num1;


NUM1 = 50;


return NUM1 + num2;

}


/*

The function of return:

1> Exit Function

2> returns a specific value to the function caller

Return value Note point

1> void represents no return value

2> If the return value type is not explicitly stated, the default is to return the int type

3> even if the return value type is explicitly declared, no value can be returned

By default, the C language does not allow the same names as two functions

*/


Char Test ()

{

Return ' A ';

}


/*

void Test (int a, int b)

{


}*/


void Test5 ()

{

}


/* Pseudo-code

void login (QQ, password)

{

1. Verify that QQ has no value

if (QQ no value) return;

2. Verify that the password has no value

If (password has no value) return;

3. Send QQ, password to the server

}*/


int Test3 ()

{

printf ("999999999\n");

}


If the return value type is not explicitly declared, the default is int type

Test2 ()

{

printf ("888888888\n");

return 10;

}


int main ()

{

int c = Test2 ();

printf ("c=%d\n", c);

Test3 ();

Test ();

/*

int a = 100;

int B = 27;

A, B is called the actual parameter of the function, referred to as argument

int c = SUM (A, b);

printf ("a=%d, b=%d, c=%d\n", A, B, c); * *


return 0;

}

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.