使用for迴圈程式設計,從鍵盤輸入整數n,再輸入n個數,求其平均值並輸出.用c語言表示

使用for迴圈程式設計,從鍵盤輸入整數n,再輸入n個數,求其平均值並輸出.用c語言表示

#include
void main()
{
int i,n,num;
double ave=0;
printf(“input n:”);
scanf(“%d”,&n);//輸入n
for(i=1;i

用C語言編寫:完成從鍵盤輸入兩個整數a和b,求平均值ave,並輸出平均值

#include
void main()
{
int a,b;
double ave;//必須是浮點型的
ave = 0.00;
a=0;
b=0;
printf(“輸入兩個整數:');
scanf(“%d %d”,&a,&b);
ave=(a+b)/2;
printf(“平均值為:%lf”,ave);
}