初学C者一习题求解。恭迎大虾!
假如我国国民生产总值的年增长率为10%,计算年后我国国民生产总值与现在相比增长多少百分比。计算公式为
P=(1+r)^n
r为年增长率;n为年数;P为与现在相比的百分比。
请大虾给出程序,还有最后怎么输出百分比结果!也就是直接显示题目要的答案 百分比!谢谢
程序代码:#include <stdio.h>
#include <math.h>
int main()
{
float r = 0.0;
float p = 0.0;
int n = 0;
printf("please enter r and n :\n");
scanf("%f%d",&r,&n);
p = pow(1+r,n);
printf("p = %%%.2f\n",100*p);
return 0;
} 