求助!3个简单的基础C程序设计

来源:百度知道 编辑:UC知道 时间:2024/05/25 14:22:40
1 编写程序输入4个数 求他们的平均值并输出

2 编写程序输入圆的半径 求圆的面积和周长

3 编写程序输入年利润 假设3% 存款总数为s 假设10000 计算一年后的本息合计并输出

1 编写程序输入4个数 求他们的平均值并输出

#include "stdio.h"
main()
{ int a,b,c,d;
float ave;
scanf("%d%d%d%d",&a,&b,&c,&d); /*请输入4个整数*/
ave=(a+b+c+d)/4.0; /*求平均数,注意是4.0不是4*/
printf("ave=%f\n",ave); /*输出*/
}

2 编写程序输入圆的半径 求圆的面积和周长 #define PI 3.14
#include "stdio.h"
main()
{ float r,c,s;
scanf("%f",&r); /*输入圆的半径*/
c=2*PI*r; /*求出圆的周长*/
s=PI*r*r; /*求出圆的面积*/
printf("c=%f, s=%f\n",c,s); /*输出*/
}

3 编写程序输入年利润 假设3% 存款总数为s 假设10000 计算一年后的本息合计并输出
#include "stdio.h"
main()
{ double a,s,t;
scanf("%lf%lf",&a,&s); /*输入年利润及存款金额*/
t=(1+s)*a; /*计算一年后的本息*/
printf("t=%f\n",ave); /*输出*/
}

举手之劳,给你写一下吧

1 编写程序输入4个数 求他们的平均值并输出
#include <stdio.h>