|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#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 [Error] expected ';' before '{' token |
|