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

This exercise involves storing student data in a struct and printing the data to

ID: 3763797 • Letter: T

Question

This exercise involves storing student data in a struct and printing the data to a table. It has two parts: Write a script to create a struct and populate it with data as specified below. It will have three fields, 'name', 'gpa', and 'tests'. The names are 'Mary Jones', 'Fred Bones', and 'Reuben Sand'. The respective gpa values are 3.4, 2.9, and 3.0. There have been three tests. Mary's grades are 91, 89, and 72. Fred's are 88. 72. and 91, and Reuben's are 69, 78, and 84. The 'tests' field will contain a vector (1 Times 3) with the three test grades. Write a function with no output value and one input argument. The input will be the struct you created in part 1. Write a table to the screen. The columns will be titled 'Name'. 'GPA', and 'Test Avg.'. The first column will contain the name, the second the GPA, and the third will contain the average of the three tests.

Explanation / Answer

#include <stdio.h>
struct name{
    char name[50];
    int tests;
    float gpa;
};
int main(){
    struct name s;
    printf("Enter information of names: ");
    printf("Enter name: ");
    scanf("%s",s.name);
    printf("Enter tests: ");
    scanf("%d",&s.tests);
    printf("Enter gpa: ");
    scanf("%f",&s.gpa);
    printf(" Displaying Information ");
    printf("Name: %s ",s.name);
    printf("Roll: %d ",s.tests);
    printf("Marks: %.2f ",s.gpa);
    return 0;
}

2)

#include <stdio.h>
//#define MAX_ARRAY 10
#define S_MAX_ARRAY 10
#define M_MAX_ARRAY 3

int main () {

char name[S_MAX_ARRAY];
int gpa[M_MAX_ARRAY];
int low = 100;
int high = 0;
int average = 0;

for(int i = 0; i<S_MAX_ARRAY;++i)
{
printf("please enter student's name");
scanf(" %s",&name[i]);
}

for(int i = 0; i<S_MAX_ARRAY;++i)
{
if(gpa[i] > high) high = gpa[i];

if(gpa[i] < low) low = gpa[i];

average+= gpa[i];

}

average/=M_MAX_ARRAY;
for(int i = 0; i<M_MAX_ARRAY;++i)
{
printf("Mark %d = %d ", i,gpa[i]);
}
printf("Average %d ", average);
printf("high = %d ", high);
printf("low = %d ", low);

return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote