#include<stdio.h>
#include<stdlib.h>
void sum(float x)
{
int n,j;
float *score=NULL;
printf("Input n=");
scanf("%d",&n);
if(n<=0&&n>100)
{
printf("wrong");
}
score=(float*)malloc(sizeof(float)*n);
float a[n];
printf("please input numbers:");
for(j=0;j<n;j++)
scanf("%f",&a[j]);
for(j=0;j<n;j++)
{
x+=a[j];
}
printf("%.2f\n",x);
}
int main()
{
while(1)
{
float x;
sum(x);
}
return 0;
#include<stdlib.h>
void sum(float x)
{
int n,j;
float *score=NULL;
printf("Input n=");
scanf("%d",&n);
if(n<=0&&n>100)
{
printf("wrong");
}
score=(float*)malloc(sizeof(float)*n);
float a[n];
printf("please input numbers:");
for(j=0;j<n;j++)
scanf("%f",&a[j]);
for(j=0;j<n;j++)
{
x+=a[j];
}
printf("%.2f\n",x);
}
int main()
{
while(1)
{
float x;
sum(x);
}
return 0;
}