求助程序报错 看了半天没看出哪里不对
#include <stdio.h>double power(double n,int p);
int main(void)
{
double x,xpow;
int exp;
printf("Enter a number and the positive integer power");
printf("to which \nthe number will be raised.enter q to quit\n");
whlie (scanf("%lf%d",&x,&exp)==2)
{
xpow = power(x,exp);
printf("%.3g to the power %d is %.5g\n",x,exp,xpow);
printf("Enter the next pair of number or q to quit.\n");
}
printf("Hope you enjoyed this power trip--bye!\n");
return 0;
}
double power(double n,int p)
{
double pow =1;
int i;
for(i=1;i<=p;i++)
pow*=n;
return pow;
}
11 2 D:\文件\code_c\6.20.c expected ';' before '{' token while写错了 whlie (scanf("%lf%d",&x,&exp)==2);
改成
while (scanf("%lf%d",&x,&exp)==2);
页:
[1]