Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m trying to get the user to enter the amount of competitors, then create an a

ID: 3547141 • Letter: I

Question

I'm trying to get the user to enter the amount of competitors, then create an array based on the number they entered.

int main()

{

int i=0,m;

double dScore[100], eScore[100], finalScores[100];

char names[100][50];

printf("This program will print out the resluts of the gymnast. ");

printf("Enter the number of competitiors: ");

scanf("%i",&i);

for(i=0;i<m;i++){

printf("Enter the Last Name, D-Score and E-Score of the competitor. ");

scanf("%s %lg %lg",names[i],&dScore[i],&eScore[i]);

if(dScore[i] < 0){break;}

}

Explanation / Answer

#include<stdio.h>
#include<conio.h>
int main()
{
int i=0,m=0;

double dScore[100], eScore[100], finalScores[100];

char names[100][50];

printf("This program will print out the results of the gymnast. ");

printf("Enter the number of competitiors: ");

scanf("%i",&m);

for(i=0;i<m;i++){

printf("Enter the Last Name, D-Score and E-Score of the competitor. ");

scanf("%s %lg %lg",names[i],&dScore[i],&eScore[i]);

if(dScore[i] < 0){
             break;
             }}


for(i=0;i<m;i++){
printf("%s %lg %lg ",names[i],dScore[i],eScore[i]);
}
getch();
return 0;

}