So I'm finally starting to get the hang of the loops and such and we were introduced to a bunch of new stuff today and had to write what to me seemed like a pretty complicated code. I looked at this over and over again and can't really see where I went wrong.
The purpose of the program is to take 3 scores for bowlers and average their scores, and assign them a rating of 1-4 stars and print the value of their average with their name and rating.
Any advice to lead me in the right direction will be greatly appreciated!
Code:
#include <stdio.h>
#include <ctype.h>
#define MAXWORD 50
int main(void)
{
int n, i, s1=0, s2=0, s3=0, numstars, avg = 0, overall_avg, highest_avg, high_avg, overall_score = 0;
char w[MAXWORD], name[MAXWORD];
printf("Enter Number of Bowlers:\n");
scanf("%d", &n);
for(i = 1; i <= n; ++i) {
printf("Enter Bowlers Name:\n");
scanf("%s", &w);
printf("Enter 3 Scores for Bowler:\n");
scanf("%d\n%d\n%d", &s1, &s2, &s3);
avg = (s1 + s2 + s3)/3;
if(avg >= 200)
numstars = 4;
if(avg >= 170 && avg <= 199)
numstars = 3;
if(avg >= 125 && avg <= 169)
numstars = 2;
if(avg >= 100 && avg <= 124)
numstars = 1;
else
numstars = 0;
printf("Bowler = %s\n", w);
printf("Average= %d\n", avg);
printf("Number of Stars = %d\n", numstars);
overall_score += avg;
if(avg> high_avg) {
strcpy (name[]) = w;
avg = highest_avg;
}
}
overall_avg = overall_score / n;
printf(“Highest Average of %d was Scored by %s \n”, highest_avg, name);
printf(“Overall Average of All Bowlers = %d\n”, overall_avg);
return 0;
}