1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
svlad2 [7]
2 years ago
9

write a 2d array c program that can capture marks of 15 students and display the maximum mark, the sum and average​

Computers and Technology
1 answer:
bekas [8.4K]2 years ago
3 0

Answer:

#include <stdio.h>  

int MaxMark(int* arr, int size) {

   int maxMark = 0;

   if (size > 0) {

       maxMark = arr[0];

   }

   for (int i = 0; i < size; i++) {

       if (arr[i] > maxMark) {

           maxMark = arr[i];

       }

   }

   return maxMark;

}

int SumMarks(int* arr, int size) {

   int sum = 0;

   for (int i = 0; i < size; i++) {

       sum += arr[i];

   }

   return sum;

}

float AvgMark(int* arr, int size) {

   int sum = SumMarks(arr, size);

   return (float)sum / size;

}

int main()

{

   int student0[] = { 7, 5, 6, 9 };

   int student1[] = { 3, 7, 7 };

   int student2[] = { 2, 8, 6, 1, 6 };

   int* marks[] = { student0, student1, student2 };

   int nrMarks[] = { 4, 3, 5 };

   int nrStudents = sizeof(marks) / sizeof(marks[0]);

   for (int student = 0; student < nrStudents; student++) {              

       printf("Student %d: max=%d, sum=%d, avg=%.1f\n",  

           student,

           MaxMark(marks[student], nrMarks[student]),

           SumMarks(marks[student], nrMarks[student]),

           AvgMark(marks[student], nrMarks[student]));

   }

   return 0;

}

Explanation:

Here is an example using a jagged array. Extend it to 15 students yourself. One weak spot is counting the number of marks, you have to keep it in sync with the array size. This is always a problem in C and would better be solved with a more dynamic data structure.

If you need the marks to be float, you can change the types.

You might be interested in
Why do you think that so many of these sources have similar names?
Anon25 [30]

Answer:

What sources? WILL ANSWER in comments

4 0
2 years ago
With a(n) ____ structure, you perform an action or task, and then you perform the next action in order.
e-lub [12.9K]
The answer is a <u>sequence structure</u>
8 0
2 years ago
Why is it important for element IDs to have meaningful names?
wlad13 [49]

Answer:

so a program can reference it; however, it does not necessarily need an event handler

Explanation:

8 0
2 years ago
You have just purchased a server with Windows Server 2016 Datacenter Edition installed. The server has 4 GB RAM, a 200 GB hard d
Elena L [17]

Answer:

a. Install more RAM

Explanation:

According to my research on information technology, I can say that based on the information provided within the question this server will not work for you purpose unless you install more RAM. This is because Hyper-V server's have a minimum requirement of 4gb, therefore if you want to run 2 servers you can divide all the resources you have since they are enough but not the RAM since you only have the bare minimum for one server. You need to add atleast 4 gb more of RAM.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

4 0
3 years ago
Explain the different types of computer software programs. Be specific and use examples.
lorasvet [3.4K]

Answer: well there are many types of software out there and let's use Microsoft for an example there a really protective company so more people would want to buy from Microsoft they have a lot of high-tech computers so and I'm not favoriting Microsoft it's just what I've use Chrome also is really good but you would kind of want to go off like reviews that you see and everything like that because I'm not a big computer tech but that's just what I know

Explanation:

3 0
3 years ago
Other questions:
  • During slideshow mode hitting the b key will do which of these
    5·1 answer
  • Select all that apply.
    8·2 answers
  • A web browser allows you to manage computer files and programs true false
    15·1 answer
  • Print a message telling a user to press the letterToQuit key numPresses times to quit. End with newline. Ex: If letterToQuit = '
    12·1 answer
  • State two functions of windows environment​
    9·1 answer
  • Jack has a fear of getting up in front of a group of people and giving a presentation. When he gave his last presentation, he ta
    5·2 answers
  • The merge sort algorithm sorts using what technique?
    8·1 answer
  • PLSS HELP ASAP ILL GIVE BRAINLIEST THANKS
    11·1 answer
  • What does Amara hope will<br> happen when Dad sits on the sofa?
    8·1 answer
  • P.W. Singer jokes about how many people are using Wang computers. What point is he making with this joke?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!