//假如我国国民生产总值的年增长率为9%,计算10年后我国国民生产总值与现在相比增长了多少百分比。计算算公式为p=(1+r)^n
#include<stdio.h>
#include<math.h>
int main()
{
int i,n;
double p,r;
i=1;
n=10;
r=0.09;
p=1.0;
while (i<=n)
{
p=p*(1+r);
i++;
}
printf("10年后,我国的国民生产总值比现在增长了%f\n",p-1);
return 0;
}
Question:函数中没有次方运算?所以 (1+r)^n 是无法使用的?