Summary of the fifth day of Camp David

Source: Internet
Author: User

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

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.