Does C language allow recursive calling of functions?

angryTom
Release: 2020-03-02 10:29:20
Original
6428 people have browsed it

Does C language allow recursive calling of functions?

Does the C language allow recursive calls of functions?

Yes. The process in which a function in C language directly or indirectly calls itself is called recursion.

1. Two necessary conditions for recursion

1. There are restrictions. When this condition is met, recursion will not Continue again.

2. Each recursive call gets closer and closer to this limit.

Recommended learning:c language video tutorial

2. Classic recursion question-finding the nth Fibonacci number

#include  #include  int fibonacci(int n) { if(n <= 2) { return 1; } else { return fibonacci(n - 1) + fibonacci(n - 2); } } int main() { int n; printf("请输入你想输出第几项的斐波那契数:\n"); scanf("%d", &n); printf("%d\n", fibonacci(n)); system("pause"); return 0; }
Copy after login

Does C language allow recursive calling of functions?

For more C language and related programming tutorials, please pay attention toPHP Chinese website!

The above is the detailed content of Does C language allow recursive calling of functions?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!