View Code of Problem 82

#include <stdio.h>
struct stu{
  char number[10];
  char name[10];
  float a,b,c; 
};
  int main()
{
  int i,n,max=0;
  float sum1=0.0,sum2=0.0,sum3=0.0,av1,av2,av3,z[10]={0};
  struct stu s[10];
  scanf("%d",&n);
  for(i=0;i<n;++i)
  {
  scanf("%s %s %f %f",&s[i].number,&s[i].name,&s[i].a,&s[i].b,&s[i].b);
    sum1+=s[i].a;
    sum2+=s[i].b;
    sum3+=s[i].c;
    z=s[i].a + s[i].b + s[i].c;
  }
  av1=sum1/n;
  av2=sum2/n;
  av3=sum3/n;
  for(i=0;i<n;++i)
    if(z[i]>z[max])
      max=i;
    printf("%0.0f %0.0f %0.0f\n",av1,av2,av3);
	printf("%s %s %0.0f %0.0f %0.0f\n",s[max].number,s[max].name,s[max].a,s[max].b,s[max].c);
}
/*
Main.c: In function 'main':
Main.c:15:3: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[10]' [-Wformat=]
   scanf("%s %s %f %f",&s[i].number,&s[i].name,&s[i].a,&s[i].b,&s[i].b);
   ^
Main.c:15:3: warning: format '%s' expects argument of type 'char *', but argument 3 has type 'char (*)[10]' [-Wformat=]
Main.c:15:3: warning: too many arguments for format [-Wformat-extra-args]
Main.c:19:6: error: assignment to expression with array type
     z=s[i].a + s[i].b + s[i].c;
      ^
*/

Double click to view unformatted code.


Back to problem 82