你能在这个问题上出错吗? [英] Can you what is wrong in this proramme?

查看:55
本文介绍了你能在这个问题上出错吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include<stdio.h>
#include<math.h>
int main(){
float x,y,z,n; 
printf("enter value in degress:");
scanf("%f",&n);
x=sin(n);
y=cos(n);
z=x*x+y*y;
printf("value of (sin and cos squares)is %f",z);
return 0;
}





我的尝试:



未定义对sin和cos的引用



What I have tried:

undefined reference to sin and cos

推荐答案

所有解释如下:未定义引用`cos' [ ^ ]



因此声明x,y,z,n为双精度并确保链接到正确的库。不知道你的环境所以无法进一步评论。



谷歌通常会为这种简单的问题提供很多答案。
All explained here: undefined reference to `cos'[^]

So declare x,y,z,n as doubles and ensure you link to the correct library. Don't know your environment so cannot comment further.

Google usually provides many answers to this simple type of problem.


正如建议da

pwasser ,这是一个链接器错误,很可能解决了在build命令中添加与maths库链接的选项,例如

As suggested da pwasser, that is a linker error, most likely solved adding the option to link with the maths library in the build command , e.g.
gcc myprogram.c -lm


这篇关于你能在这个问题上出错吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆