Dark Horse programmer------<a href= "http://www.itheima.com" target= "blank" >java training, Android training, iOS training,. NET training </a>, look forward to communicating with you! -------
Declaration and prototype of three functions
01 before a function call, the called function should be declared, indicating the return value type of the function and the number and type of formal parameters.
General format for function declarations:
The function returns a value of type function name (parameter type 1 parameter name 1, .....). );
* The position of the function declaration, one is to declare the function in the keynote function, and the other is to declare the function outside of all functions.
//programming to seek 1+2en+....+nen#include<stdio.h>DoublePowerintPintq);DoubleSigmaintMintn);intMain () {intx, y; Doublesum; printf ("Please enter two functions: \ n"); scanf ("%d%d",&x,&y); Sum=Sigma (x, y); printf ("sum=%f\n", sum);}DoublePowerintPintq) { inti; Doubleproduct=1; for(i=1; i<=q; i++) {Product= product*p; returnproduct; } }DoubleSigmaintMintN) { inti; DoubleP, sum=0; for(i=1; i<m; i++) {p=Power (m,n); Sum= sum+p; returnsum; } }
Nesting and recursion of four functions
01 nested invocation refers to the invocation of another function in the definition of one function, which is called by another function in the called function.
The 02 function calls itself, directly or indirectly, in the process of invocation, called recursive invocation of functions, also known as recursive functions
//solving the factorial of integer n by recursive method#include<stdio.h>DoubleFactintm);intMain () {intx; Doubleresult; printf ("Please enter an integer: \ n"); scanf ("%d",&x); Result=fact (x); if(Result = =-1) {printf ("result error \ n"); } Else{printf ("%d!=%f\n", X,result); } }DoubleFactintm) { if(m<0) { return-1; } Else if(m==0|| m==1) { return 1; } Else returnM*fact (M-1);}
10-Dark Horse programmer------C Language Learning notes---Declaration and prototyping of C-language functions