tan(x)函数详解

首页 / C++入门教程 / tan(x)函数详解

该函数查找以弧度指定的角度的切线。

tan - 语法

float tan(float x);
double tan(double x);
long double tan(long double x);
double tan(integral x);

Note: 如果传递的值是整数类型,则将其强制转换为double。

tan - 参数

x :以弧度表示的值。

tan - 返回值

它返回以弧度表示的角度的切线。

tan - 例子1

让我们看一个简单的例子,当x的值为正时。

无涯教程网

#include <iostream>  
#include<math.h>  
using namespace std;  
int main()  
{  
   float degree=10;  
   float radian=degree*3.14/180;  
   cout<<"Tangent of an angle is : "<<tan(radian);  
   return 0;  
}  

输出:

Tangent of an angle is : 0.176236

在此示例中,当度数的值等于10时,tan()函数计算角度的切线。

tan - 例子2

让我们看一个简单的例子,当度的值为负时。

#include <iostream>  
#include<math.h>  
using namespace std;  
int main()  
{  
  float degree= -60;  
  float radian=degree*3.14/180;  
  cout<<"Tangent of an angle is :"<<tan(radian);  
  return 0;  
}  

输出:

Tangent of an angle is :-1.72993 

在此示例中,tan()函数在度的值为负(即-60)时计算角度的切线。

链接:https://www.learnfk.comhttps://www.learnfk.com/c++/cpp-math-tan-function.html

来源:LearnFk无涯教程网

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

如何设计一个秒杀系统 -〔许令波〕

苏杰的产品创新课 -〔苏杰〕

雷蓓蓓的项目管理实战课 -〔雷蓓蓓〕

手把手教你玩音乐 -〔邓柯〕

Tony Bai · Go语言第一课 -〔Tony Bai〕

搞定音频技术 -〔冯建元 〕

人人都用得上的数字化思维课 -〔付晓岩〕

快速上手C++数据结构与算法 -〔王健伟〕

云时代的JVM原理与实战 -〔康杨〕

好记忆不如烂笔头。留下您的足迹吧 :)