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

keeping track of 3 students and their 4 exam grades for each of their 2 subjects

ID: 3761886 • Letter: K

Question

keeping track of 3 students and their 4 exam grades for each of their 2 subjects. Hence, it uses a 3(students)-2(subjects)-4(exams) array. This problem is featured in class. Now, for this assignment, you are required to rewrite the code to work with 2(subjects)-3(students)-4(exams) array (2x3x4 array). The functions must perform: a) Printing an average of all grades b) Finding average grade for each subject for each student c) Finding the average grade for each student in both subjects You ARE NOT ALLOWED to pass the whole array to all three functions. Therefore, determine how many dimensions need to be passed to each function and write the appropriate code.

Explanation / Answer

the array is of the form 2*3*4 so

the array is of the form where e is the exam {{ e,e,e,e},{ e,e,e,e},{ e,e,e,e}}

{ e,e,e,e},{ e,e,e,e},{ e,e,e,e}};

these simply presents that the exam marks of two students and each bracket ({ })specifies the individual student marks .

the code is as follows.

let i be subject and j is student k is exam

g/g1/g2 are individual students marks average.

tot is for total marks

#include <iostream>
using namespace std;
int main()
{
    int marks[2][3][4];
int i,j,k;
int g,g1,g2;
int m,n;
    void tot(int,int);
    void sub(int,int);
    void sum(int,int,int);

for(i=0;i<2;i++)
{
for(j=0;j<3;j++)
{
for(k=0;k<4;k++)
{
std::cin>>marks[i][j][k];
}
}
}
for(j=0;j<3;j++)
{
for(k=0;k<4;k++)
{
m=m+marks[0][j][k];
n=n+marks[1][j][k];
}
}

for(i=0;i<2;i++)
{
for(k=0;k<4;k++)
{

g=g+marks[i][0][k];
}
}
for(i=0;i<2;i++)
{
for(k=0;k<4;k++)
{
g1=g1+marks[i][1][k];
}
}
for(i=0;i<2;i++)
{
for(k=0;k<4;k++)
{
g2=g2+marks[i][2][k];
}
}
sum(g,g1,g2);
tot(m,n);
sub(m,n);
return 0;
  
}

void sum(int g,int g1,int g2)
{
float avg,avg1,avg2;
avg=g/8;
avg1=g1/8;
avg2=g2/8;
std::cout<<g;
std::cout<<g1;
std::cout<<g2;
}
void tot(int m,int n)
{int s=0;
s=m+n/24;
std::cout<<s;
}
void sub(int m,int n)//
{
std::cout<<m/12;
std::cout<<n/12;
}