# C Programming – HackerRank Solution | 2D ARRAYS- Internal Evaluations for students |

### (HackerRank) Write a Modular C Programming code to solve 2D ARRAYS- Internal Evaluations for students, KLE Technological University is one of the reputed institutions in Karnataka.

KLE Technological University is one of the reputed institutions in Karnataka. Every year more than 1000 students will join the Institution for the UG and PG Programs. “C programming for Problem Solving” course is the basic programming course that every student studies in the first semester. This year there are N numbers of students studying the course The class teacher conducts X number of Internal Evaluations for the same.

Apply the PSF to read and display the marks of each student in X internal Evaluations. Calculate the average marks in each evaluation as well as average marks of each student.

Input Format

First line indicates N and X values. N is number of students and X is number of Internal Evaluations of every student.

Constraints

N and X should be greater than 0

Output Format

Dispaly Internal Evaluations Marks of all the students.

Display average marks in each evaluation.

Display averge marks of each student.

Sample Input 0

```2 4
1 2 3 4
5 6 7 8
```

Sample Output 0

```1 2 3 4
5 6 7 8
Internal Evaluation average: 3.0000 4.0000 5.0000 6.0000
Students average: 2.5000 6.5000
```

Sample Input 1

```-4 -9
```

Sample Output 1

`Invalid input`

CODE:

```#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

void read(int m,int n,int matrix[m][n]);
void display(int m,int n,int matrix[m][n]);
void avg_score_evaluation(int m,int n,int matrix[m][n]);
void avg_score_student(int m,int n,int matrix[]);
int main() {
int m,n;
scanf("%d%d",&m,&n);
if(m>0 && n>0)
{
int matrix[m][n];
display(m,n,matrix);
avg_score_evaluation(m,n,matrix);
avg_score_student(m,n,matrix);
}
else{
printf("Invalid input");
}
return 0;
}
void read(int m,int n,int matrix[m][n])
{
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
scanf("%d",&matrix[i][j]);
}
}
}
void display(int m,int n,int matrix[m][n])
{
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
printf("%d ",matrix[i][j]);
}
printf("\n");
}
}
void avg_score_evaluation(int m,int n,int matrix[m][n])
{
float evaluation_sum[n];
printf("Internal Evaluation average: ");
for(int i=0;i<n;i++)
{
evaluation_sum[i]=0;
for(int j=0;j<m;j++)
{
evaluation_sum[i]+=matrix[j][i];
}
printf("%0.4f ",(float)evaluation_sum[i]/m);
}
printf("\n");
}
void avg_score_student(int m,int n,int matrix[m][n])
{
float student_sum[m];
printf("Students average: ");

for(int i=0;i<m;i++)
{
student_sum[i]=0;
for(int j=0;j<n;j++)
{
student_sum[i]+=matrix[i][j];
}
printf("%0.4f ",(float)student_sum[i]/n);
}
}

```

OUTPUT

```Congratulations, you passed the sample test case.

Click the Submit Code button to run your code against all the test cases.

Input (stdin)

2 4
1 2 3 4
5 6 7 8

1 2 3 4
5 6 7 8
Internal Evaluation average: 3.0000 4.0000 5.0000 6.0000
Students average: 2.5000 6.5000
Expected Output

1 2 3 4
5 6 7 8
Internal Evaluation average: 3.0000 4.0000 5.0000 6.0000
Students average: 2.5000 6.5000```

Please find some more codes of Loops, Condition Statements, 1D Arrays, 2D Arrays, Strings, Pointers, Data Structures, Files, Linked lists, Stacks, Queues, Binary Trees, MISC, Solved model question papers & Hacker Rank all solutions on the below page:

Top 100+ C Programming codes – KLE Technological University #### Welcome to FactsPrime

Sorry, We have detected that you have activated Ad-Blocker. Please Consider supporting us by disabling your Ad Blocker, It helps us in maintaining this website. To View the content, Please disable adblocker and refresh the page.

Thank You !!!