c+pow函数的头文件_pow()函数以及C ++中的示例
c+pow函數的頭文件
C ++ pow()函數 (C++ 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);Parameter(s): x, y – are the numbers to calculate x^y.
參數: x,y –是用于計算x ^ y的數字。
Return value: double – it returns double value that is calculate result of x to the power of y.
返回值: double-返回double值,它是x的計算結果乘以 y的冪。
Example:
例:
Input:float x = 2;float y = 3;Function call:pow(x,y);Output:8C ++代碼演示pow()函數的示例 (C++ code to demonstrate the example of pow() function)
// C++ code to demonstrate the example of // pow() function#include <iostream> #include <cmath> using namespace std;// main code section int main() {float x;float y;//input the valuescout<<"Enter the value of x: ";cin>>x;cout<<"Enter the value of y: ";cin>>y;// calculate the powerfloat result = pow(x,y);cout<<x<<" to the power of "<<y<<" is = "<<result;cout<<endl;return 0; }Output
輸出量
First run: Enter the value of x: 10 Enter the value of y: 5 10 to the power of 5 is = 100000Second run: Enter the value of x: 10.23 Enter the value of y: 1.5 10.23 to the power of 1.5 is = 32.72Third run: Enter the value of x: 10 Enter the value of y: 0 10 to the power of 0 is = 1 Fourth run: Enter the value of x: 0 Enter the value of y: 1.5 0 to the power of 1.5 is = 0翻譯自: https://www.includehelp.com/cpp-tutorial/pow-function-with-example.aspx
c+pow函數的頭文件
總結
以上是生活随笔為你收集整理的c+pow函数的头文件_pow()函数以及C ++中的示例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MySQL 精选 60 道面试题(含答案
- 下一篇: 聊聊并发编程的10个坑