【C程序设计】习题3.1 计算增长百分比

avatar

azurekiln

1.假如我国国民生产总值的年增长率为7% ,计算10年后我国国民生产总值与现在相比增长多少百分比。计算公式为:


(其中r为年增长率,n为年数,p为与现在相比的倍数)

程序源代码:

#include <stdio.h>
#include <math.h>
int main() {
    //我国国民生产总值的年增长率 
    float r = 0.07;
    //10年 
    int n = 10;
    //与现在相比的倍数
    float p;
    //计算10年后我国国民生产总值与现在相比增长了多少百分比 
    p = pow(1 + r, n);
    printf("10年后与现在相比的倍数为:%f", p);
    return 0;
}

运行结果:


扫描二维码,在手机上阅读
收藏
请先 登录 再评论
powered by emlog pro
服务器供应商 景云数据

友情链接
白衣Ink


sitemap