我想在C中編譯一個程序來返回數字的平方,例如1^2 = 1,但程序編譯時沒有問題,總是返回值爲0.在C中的平方問題#
我做錯了什麼?
#include <stdio.h>
#include <math.h>
int main(int argc, const char * argv[])
{
/* Define temporary variables */
double value1, value2;
double result;
/* Assign the values we will use for the pow calculation */
value1 = 0;
value2 = 0;
/* Calculate the result of value1 raised to the power of value2 */
result = pow(value1, value2);
/* Display the result of the calculation */
printf("%f raised to the power of %f is %f\n", value1, value2, result);
return 0;
}
頂部的描述表明它只適用於正方形。你可以很容易地完成,只需要將它乘以沒有pow()函數的自己。此外,如果它的0,那麼你有問題設置變量....顯然,描述已不存在...但它是。 –
@ M.Jameson請檢查我的答案 – GeneCode