Ok so I implemented strcpy. Can someone show me how to do the two dimensional array for the names?
Code:
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main(void)
{
char name[10];
char name1[20];
int j,score,sum,avg,ducknum,abvavg;
int a[5];
abvavg = 0;
ducknum = 0;
sum = 0;
for(j = 0; j < 3; j++)
{
printf("Please enter the name\n");
scanf("%s",&name);
printf("Enter score\n");
scanf("%d",&score);
a[j] = score;
strcpy(name1,name);
sum = sum + score;
}
avg = sum / 4;
for(j = 0; j < 3; j++)
{
if(a[j] > avg)
{
abvavg = abvavg + 1;
}
if(a[j] == 0)
{
ducknum = ducknum + 1;
}
if(a[j] > 50)
{
printf("%s hit above 50 with a score of %d\n",name1,a[j]);
}
}
printf("The amount of batsmen who made a duck is:%d\n",ducknum);
printf("The amount of batsmen who scored above the team average is:%d\n",abvavg);
printf("The average is:%d\n",avg);
getch();
return 0;
}