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

Write a C program that perfomrs the following task: (Using appropriate functions

ID: 650021 • Letter: W

Question

Write a C program that perfomrs the following task:

(Using appropriate functions and parameter passing. You can include either void or nonvoid functions. Your main should consist of only declarations and function calls.)

Calculate and print the average exam 1 score and average exam 2 score for four students.

Note: I've completed the program already but I'm not getting the right output solution for the average of exam1 (avge1) and exam 2 (avge2). Could someone take a look at it to help me correct it?

Code begins here:

#define _CRT_SECURE_NO_WARNINGS

#include<stdlib.h>

#include<stdio.h>

void load (int*e1, int *e2)

{

printf("enter the two exam scores ");

scanf("%d%d", &(*e1), &(*e2));

}

void calc(int e1, int e2, float *avge1, float *avge2, int counte1, int counte2)

{

counte1=+e1;

counte2=+e2;

*avge1=counte1/(float)4;

*avge2=counte2/(float)4;

}

void print (int avge1, int avge2)

{

printf(" the average of the exam 1 is %d ", avge1);

printf("the average of the exam 2 is %d ", avge2);

}

int main()

{

int e1, e2, counte1,counte2;

float avge1,avge2;

  

load(&e1, &e2);

calc(e1, e2,&avge1,&avge2,counte1,counte2);

  

fflush(stdin);

load(&e1, &e2);

calc(e1, e2,&avge1,&avge2,counte1,counte2);

  

fflush(stdin);

load(&e1, &e2);

calc(e1, e2,&avge1,&avge2,counte1,counte2);

  

fflush(stdin);

load(&e1, &e2);

calc(e1, e2,&avge1,&avge2,counte1,counte2);

  

print(avge1,avge2);

  

}

Code ends here.

My output reads:

enter the two exam scores 75 85

enter the two exam scores 94 89

enter the two exam scores 58 75

enter the two exam scores 10 8

the average of the exam 1 is 2

the average of the exam 2 is 2

Program ended with exit code: 0

Explanation / Answer

#define _CRT_SECURE_NO_WARNINGS #include #include void load(int *e1, int *e2) { printf("enter the two exam scores: "); scanf("%d%d",&(*e1),&(*e2)); } void calc(int e1, int e2, float *avge1, float *avge2, int counte1, int counte2) { counte1=0; counte2=0; counte1=+e1; counte2=+e2; *avge1=counte1/4; *avge2=counte2/4; } void print(int avge1, int avge2) { printf(" the average of the exam 1 is %d ",avge1); printf(" the average of the exam 2 is %d ",avge2); } int main() { int e1, e2, counte1,counte2; float avge1,avge2; load(&e1, &e2); calc(e1, e2,&avge1,&avge2,counte1,counte2); print(avge1,avge2); fflush(stdin); load(&e1, &e2); calc(e1, e2,&avge1,&avge2,counte1,counte2); print(avge1,avge2); fflush(stdin); load(&e1, &e2); calc(e1, e2,&avge1,&avge2,counte1,counte2); print(avge1,avge2); fflush(stdin); load(&e1, &e2); calc(e1, e2,&avge1,&avge2,counte1,counte2); print(avge1,avge2); }
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