/workspace/2.c/main.cpp:9:18: error: use of undeclared identifier 'sum'; did you mean 'sun'? printf ("%f",sum(first,second)) ; ^~~ sun /workspace/2.c/main.cpp:3:7: note: 'sun' declared here float sun(float,float); ^ 1 error generated.
时间: 2024-03-01 19:54:56 浏览: 89
这个错误提示说“sum”未定义,但是你定义的函数名字是“sun”,这是一个拼写错误。在第9行的 printf 语句中,你应该调用“sun”函数而不是“sum”函数。修改后的代码如下:
```
#include<iostream>
#include<stdio.h>
float sun(float, float);
int main() {
float first, second;
first = 123.23;
second = 99.09;
printf("%f", sun(first, second));
}
float sun(float a, float b) {
return a + b;
}
```
修改后的代码可以正确地计算并输出两个数的和。
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pptx](https://img-home.csdnimg.cn/images/20241231044947.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![xmi](https://img-home.csdnimg.cn/images/20250102104920.png)
![gz](https://img-home.csdnimg.cn/images/20210720083447.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)