Big tea today tells us about the recursion of C language and the call of functions. You can create the source file of functions in other files and call them in the main file, you can save on multiple lines of code in the main function. Once a program fails, debugging is very convenient. You do not need to find some small errors in a large segment of code.
Recursive statements are similar to loops and have judgment statements. When the judgment statement is not true, the conditions of the judgment statement are skipped and the else statement is used for recursion until the conditions are not met.
#include <stdio.h>int f(int n);int n;int main(int argc, const char * argv[]){ printf("%d\n", f(10));}int f (int n){ if(n==1||n==2) { return 1; } else { return f(n-1)+f(n-2); }}
Function prototype 1
#include "file1.h"int b;
Function prototype 2
#include "file2.h"int a;
Main Function
#include <stdio.h>int f(int n);int n;int main(int argc, const char * argv[]){ printf("%d", f(6));} int f (int n) { if(n==1||n==2) { return 1; } else { return f(n-1)+f(n-2); }}
Summary of the fifth day of Camp David