C 递归函数调用概念

标签 c function recursion

/*Program to print all the numbers between a lower bound and a upper bound values*/     

#include<stdio.h>
#include<stdlib.h>
void recur(int a, int b);
int main(void)
{
    int x,y;
    printf("Enter the lower and upper bound values: \n");
    scanf("%d %d",&x,&y);
    void recur(x,y);
    return 0;
}
void recur(int a,int b)
{
    if(a<b)
    {
        printf("%d /n",a);
        a++;
        void recur(a,b);
    }
}

我得到的输出是:

Enter the lower and upper bound values:
    10
    50
    process returned 0.

语法或返回类型有什么问题吗? 我刚刚开始学习 c.需要帮助

最佳答案

两者

void recur(x,y);
void recur(a,b);

声明函数(原型(prototype))。要调用它们,请将它们更改为

recur(x,y);
recur(a,b);

关于C 递归函数调用概念,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31366105/

相关文章:

javascript - 匿名函数在 jQuery/Javascript 中如何工作?

选择了 mysql 枚举的 php 函数

list - 如何通过不使用 "list comprehensions"获取列表中元素的索引?

你能帮我找出这个C递归函数的逻辑错误吗?

c - C 结构填充是否使这种使用不安全?

c - 字符串编辑器(无法正常工作)

c++ - 用 2x1 block 平铺 2xM 阵列以最大化差异 - INOI 2008,P2

multithreading - 在golang中并行递归扫描树

c - (const T v) 在 C 中从来都不是必需的,对吗?

c - 不清楚为什么十六进制值的第一个数字显示为其自身的 +8 版本。套接字CAN