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
Candy Kane Cosmetics (CKC) produces Leslie Perfume, which requires chemicals and labor. Two production processes are available:
Vilka [71]

Answer:

  1. Divide the resources into three parts using the corresponding process 1, process 1, and process 2 formats to maximize the use of the resources.
  2. Get the expected revenue by calculating the product of the total perfume in ounce and the price of an ounce of perfume.
  3. Increase the advertisement hours of the product.
  4. subtract the advert fee from the generated revenue to get the actual revenue.
  5. subtract the cost of production from the actual revenue to get the actual profit.

Explanation:

The get maximum profit, all the resources must be exhausted in production. The labor is divided into a ratio of 1:1:2 ( which is 5000, 5000, 1000), while the chemical units are in the ratio of 2:2:3 (10000,10000,15000). This would produce in each individual processes; 15000, 15000 and 25000 oz, which is a total of 55000 oz of perfume.

The expected revenue is $275000. If 1000oz from the 55000oz of perfume is sold without advertisement, model Jenny's awareness of the perfume increases the demand by 200oz per hour, therefore, 24hours would field 4800oz demanded, which would only take 270 hours to distribute all remaining perfumes.

The cost of production would be $130000 for labor and chemical resources plus the advert cost of $27000 ( 270 hours by 100) which is a total cost of $157000. The actual profit is $118000 ( $275000 - $157000).

3 0
2 years ago
How can i become an ailen?
DIA [1.3K]
Go to a different state as a migrant and then your a alien
8 0
3 years ago
Read 2 more answers
Wendell notices that the company's top executives share a belief that managers are directly responsible for the organization's s
Debora [2.8K]
This belief reflects an omnipotent view of management.
8 0
2 years ago
Using complete sentences post a detailed response to the following.
KatRina [158]

Answer:A couple disadvantaged are the migraines that is can cause. And it can cause eye strain there are alot of things that could hurt your eyes. Like being in virtual reality for to long. It can very rarely make you go blind.

Explanation: sorry if its wrong

8 0
3 years ago
Chemical equations of Carbon + water​
Setler79 [48]

Answer:

Aqueous carbon dioxide, CO2 (aq), reacts with water forming carbonic acid, H2CO3 (aq). Carbonic acid may loose protons to form bicarbonate, HCO3- , and carbonate, CO32-. In this case the proton is liberated to the water, decreasing pH. The complex chemical equilibria are described using two acid equilibrium equations.

PLS MARK AS BRAINLIEST

8 0
3 years ago
Other questions:
  • Where does the VLookup function find its lookup values?
    14·1 answer
  • Write an application that instantiates five Recording objects and prompts the user for values for the data fields. Then prompt t
    13·1 answer
  • Examine the following algorithm.
    9·1 answer
  • Universal Containers uses a custom field on the account object to capture the account credit status. The sales team wants to dis
    7·1 answer
  • Write a program to read a list of exam scores given as integer percentages in the range O to 100. Display the total number of gr
    11·1 answer
  • What time is spellrd the same forwards and backwards​
    11·1 answer
  • How to solve household arithmetic​
    7·1 answer
  • How do you loop a makebeat in earsketch
    11·1 answer
  • Which of the following best explains what happens when a new device is connected to the Internet?
    9·1 answer
  • Basics of visual basic
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!