gpt4 book ai didi

c - 函数入门需要帮助输入数字(初学者)

转载 作者:行者123 更新时间:2023-11-30 16:11:49 27 4
gpt4 key购买 nike

我想知道如何使用下面编写的代码使用函数输入数字,并且对如何输入并给出输出有点困惑,我基本上刚刚开始使用 0 级函数。

int addTwoInt(int a, int b);

int main(void)
{
printf("Enter a number: ");
scanf("%d", &addTwoInt(<#int a#>, <#int b#>));
// printf("The two numbers added are %d", addTwoInt);
}

int addTwoInt(int a, int b)
{
int sum;
sum = a + b;
return sum;
printf("The sum of the numbers are %d", sum);
}

最佳答案

int addTwoInt(int a, int b);
int main(void)
{
int x;
int y;
printf("Enter a number: ");
scanf("%d", &x);
scanf("%d", &y);

int z = addTwoInt(x, y);
printf("%d", z);

//printf("The two numbers added are %d", addTwoInt);
}

int addTwoInt(int a, int b)
{
int sum;
sum = a + b;
printf("The sum of the numbers are %d", sum);
return sum;
}

关于c - 函数入门需要帮助输入数字(初学者),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58491477/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com