Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

could you take a look and edit my code it keeps printing out random garbage #include #include #include #include #include int main(void) { char team[100][50];

could you take a look and edit my code it keeps printing out random garbage

#include

#include

#include

#include

#include

int main(void) {

char team[100][50];

char firstname[20];

char secname[20];

char lastname[10];

char print[22];

int points[100];

int z=0;

int y=0;

int x=0;

int max;

int gamewon[100];

int glostreg[22];

int glostover[100];

int glostshoot[100];

setvbuf(stdout,NULL,_IONBF,0);

printf("Enter team data:");

while(x

scanf("%s", firstname);

scanf("%s", secname);

scanf("%s", lastname);

strcat(firstname, " ");

strcpy(team[x], firstname);

strcat(secname, " ");

strcat(team[x], secname);

if (isalpha(lastname[0])) {

strcat(team[x], lastname);

scanf("%d", &gamewon[x]);

} else {

gamewon[x] = atoi(lastname);

}

scanf("%d %d %d", &glostreg[x], &glostover[x], &glostshoot[x]);

points[x]=(gamewon[x]*2)+(glostshoot[x]*1)+(glostover[x]*1);

x=x+1;

printf("Team W L OTL SOL PTS ");

for (x = 0; x

printf("%-25s %3.1d %3.1d %3.1d %3.1d %3.1d ", team[x], gamewon[x],

glostreg[x], glostover[x], glostshoot[x], points[x]);

}

printf(" ");

printf("Team W L OTL SOL PTS ");

//from the lecture slides//

for (x = 0; x

max = INT_MIN;

for (y = 0; y

if (!print[y] && points[y] > max) {

max = points[y];

z = y;

}

}

printf("%-25s %3.1d %3.1d %3.1d %3.1d %3.1d ", team[z], gamewon[z],

glostreg[z], glostover[z], glostshoot[z], points[z]);

print[z] = 1;

}

}

return EXIT_SUCCESS;

}

ITS SUPPOSED To DO THIS :image text in transcribedimage text in transcribedimage text in transcribed

4. prints a second table with the ordered by descending ts-iftwo teams have the same number of points they point should be in alphabetical order by team name (see sample output) Sample output Enter team data Brandon Wheat Kings 25 19 Calgary Hitmen 19 23 Edmonton Oil Kings 30 Everett silver ips 30

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions

Question

Advance warning and an explanation for the layoff.

Answered: 1 week ago