Answer to Question #181634 in C for Cosmas Nyathi

Question #181634

Write a program that allows the user to enter students’ names followed by their test scores and

outputs the following information (assume that maximum number of students is 50). Note you will

need to make use of an array.

a. The average score.

b. Names of all students whose test scores are below the average, with an appropriate

message.

c. Highest test score and the name of all students having the highest score. 


1
Expert's answer
2021-04-15T02:57:15-0400
#include <stdio.h>
#include <stdlib.h>


#define MAX_STUDENTS 50


struct Student
{
    char name[20];
    int score;
};


void InitializeStudents(struct Student students[])
{
    int i;
    for(i = 0; i < MAX_STUDENTS; ++i)
    {
        printf("Enter name and score of %d student!\n", i+1);
        printf("Enter name: ");
        scanf("%s", &students[i].name);
        printf("Enter score: ");
        scanf("%d", &students[i].score);
    }
}


void PrintInfo(struct Student students[])
{
    int i;
    printf("\t\tInfo about students:\n\n");
    for(i = 0; i < MAX_STUDENTS; ++i)
    {
        printf("The %s's score is %d\n", students[i].name, students[i].score);
    }
}




int main()
{
    struct Student students[MAX_STUDENTS];
    InitializeStudents(students);
    PrintInfo(students);


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS