編寫一個接受正整數n的C函數並返回2^n。陳述任何假設。查找電源
所以這是正確的....?
#include<math.h>
double power(int x)
{
int i,pow,n, ans;
ans=1;
printf ("Enter the number and power:");
scanf ("%d%d", &pow, &n);
for(i=1;i<=pow; i++)
{
ans = ans *n
return pow(2,n);
}
int main()
{
int x, y,c;
c=pow(x,y);
printf("%d to the power %d is %d",n,pow,ans);
getch();
}
已經試過了麼?有一個簡單的函數原型,但沒有實際的代碼來執行任務...你到目前爲止嘗試過什麼? SO不是關於我們做你的功課... – NirMH