c语言幂函数_C ++中的幂函数
c语言幂函数
C ++幂函数 (C++ power functions)
Power functions are used to calculate the powers (like, raise to power, square root, cubic root, etc). There are following power functions which are the library functions of cmath header.
幂函数用于计算幂(例如,提高到幂,平方根,立方根等)。 有以下幂函数 ,它们是cmath标头的库函数。
pow() function
pow()函数
sqrt() function
sqrt()函数
cbrt() function
cbrt()函数
hypot() function
hypot()函数
1)pow()函数 (1) pow() function)
pow() function is a library function of cmath header (<math.h> in earlier versions), it is used to find the raise to the power, it accepts two arguments and returns the first argument to the power of the second argument.
pow()函数是cmath标头的库函数(在早期版本中为<math.h>),用于查找幂的加数,它接受两个参数并将第一个参数返回为第二个参数的幂。
Syntax of pow() function:
pow()函数的语法:
pow(x, y);
2)sqrt()函数 (2) sqrt() function)
sqrt() function is a library function of cmath header (<math.h> in earlier versions), it is used to find the square root of a given number, it accepts a number and returns the square root.
sqrt()函数是cmath标头(在早期版本中为<math.h> )的库函数,用于查找给定数字的平方根,它接受数字并返回平方根。
Note: If we provide a negative value, sqrt() function returns a domain error. (-nan).
注意:如果我们提供负值,则sqrt()函数将返回域错误。 ( -nan )。
Syntax of sqrt() function:
sqrt()函数的语法:
sqrt(x);
3)cbrt()函数 (3) cbrt() function)
cbrt() function is a library function of cmath header, it is used to find the cubic root of a given number, it accepts a number and returns the cubic root.
cbrt()函数是cmath标头的库函数,用于查找给定数字的立方根 ,它接受数字并返回立方根。
Syntax of cbrt() function:
cbrt()函数的语法:
cbrt(x);
4)hypot()函数 (4) hypot() function)
hypot() function is a library function of cmath header, it is used to find the hypotenuse of the given numbers, it accepts two numbers and returns the calculated result of hypotenuse i.e. sqrt(x*x + y*y).
hypot()函数是cmath标头的库函数,用于查找给定数字的斜边,接受两个数字并返回斜边的计算结果,即sqrt(x * x + y * y) 。
Syntax of hypot() function:
hypot()函数的语法:
hypot(x, y);
C ++程序演示幂函数示例 (C++ program to demonstrate example of power functions)
// C++ program to demonstrate example of
// power functions
#include <iostream>
#include <cmath>
using namespace std;
// main() section
int main()
{float x, y;
float result;
//pow() function
x = 12;
y = 4;
result = pow(x,y);
cout<<x<<" to the power of "<<y<<" is : "<<result;
cout<<endl;
//sqrt() function
x = 2;
result = sqrt(x);
cout<<"square root of "<<x<<" is : "<<result;
cout<<endl;
//cbrt() function
x = 2;
result = cbrt(x);
cout<<"cubic root of "<<x<<" is : "<<result;
cout<<endl;
//hypot() function
x = 2;
y = 3;
result = hypot(x,y);
cout<<"hypotenuse is : "<<result;
cout<<endl;
return 0;
}
Output
输出量
12 to the power of 4 is : 20736
square root of 2 is : 1.41421
cubic root of 2 is : 1.25992
hypotenuse is : 3.60555
翻译自: https://www.includehelp.com/cpp-tutorial/power-functions.aspx
c语言幂函数
c语言幂函数_C ++中的幂函数相关推荐
- c语言字符幂函数怎么编写,c语言幂函数_C ++中的幂函数
c语言幂函数 C ++幂函数 (C++ power functions) Power functions are used to calculate the powers (like, raise t ...
- 幂函数的c语言程序,C ++中的幂函数
C ++幂函数 幂函数用于计算幂(例如,提高到幂,平方根,立方根等).有以下幂函数,它们是cmath标头的库函数.pow()函数 sqrt()函数 cbrt()函数 hypot()函数 1)pow() ...
- 线性回归 c语言实现_C ++中的线性回归实现
线性回归 c语言实现 Linear regression models the relation between an explanatory (independent) variable and a ...
- c语言稀疏矩阵_C中的稀疏矩阵
c语言稀疏矩阵 In this tutorial, we are going to learn about the sparse matrix in C. 在本教程中,我们将学习C语言中的稀疏矩阵. ...
- python画指数函数图像_解决python中的幂函数、指数函数问题
最近在调代码,碰到幂函数.指数函数,总是提示 ValueError: math domain error ValueError: negative number cannot be raised to ...
- python中幂函数_解决python中的幂函数、指数函数问题
最近在调代码,碰到幂函数.指数函数,总是提示 ValueError: math domain error ValueError: negative number cannot be raised to ...
- python自然对数为底的指数函数_解决python中的幂函数、指数函数问题
最近在调代码,碰到幂函数.指数函数,总是提示 ValueError: math domain error ValueError: negative number cannot be raised to ...
- python幂函数_解决python中的幂函数、指数函数问题
最近在调代码,碰到幂函数.指数函数,总是提示 ValueError: math domain error ValueError: negative number cannot be raised to ...
- python 幂函数 幂为小数_解决python中的幂函数、指数函数问题
最近在调代码,碰到幂函数.指数函数,总是提示 ValueError: math domain error ValueError: negative number cannot be raised to ...
- c语言面向对象编程中的类_C ++中的面向对象编程
c语言面向对象编程中的类 Object oriented programming, OOP for short, aims to implement real world entities like ...
最新文章
- python日历gui_python GUI库图形界面开发之PyQt5日期时间控件QDateTimeEdit详细使用方法与实例...
- java git服务器_Windows平台下Git服务器搭建
- Java-Java5.0注解解读
- OpenCv cv::Mat 转 IplImage 函数
- lenovo Think Centre TCM 开发环境搭建
- 通过 dhcp-agent 访问 Metadata - 每天5分钟玩转 OpenStack(168)
- python web scraping
- 配置HAProxy支持https协议
- vue 通信、传值的多种方式(超详细)
- 如何修改TextView链接点击实现(包含链接生成与点击原理分析)
- WINDOWS8.1 安装 .NET35方法
- 百度景鲲:9月15日发布小度真无线智能耳机
- 这家大厂手机业务也凉了 改做手表?官方回应让人放心了...
- linux中shell数组的使用和建立
- About Exception Handling
- linux读usb蓝牙数据,嵌入式Linux下USB蓝牙设备驱动.pdf
- 我爱淘冲刺阶段站立会议2每天任务6
- ACM1008玛雅日历
- PNG格式的证件照怎么转成JPG格式?教你一招轻松转换
- it is dying gasp packet 说明