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]
3 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]3 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
Consider the following instructions carefully. What is wrong? Drive to the store Pay the cashier Select your purchases Drive hom
Levart [38]

Answer:

The correct answer is: The instructions are not correctly ordered.

Explanation:

The instructions are not correctly ordered because to pay the cashier, you first have to select your purchases.

The correct order for the instructions:

  • Drive to the store.
  • Select your purchases.
  • Pay the cashier.
  • Drive home.
7 0
3 years ago
Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both floats) as input, and output the ga
Ierofanga [76]

Answer:

x^{2} \left[\begin{array}{ccc}1&2&3\\4&5&6\\7&8&9\end{array}\right] \int\limits^a_b {x} \, dx  \lim_{n \to \infty} a_n \sqrt{x} \sqrt[n]{x} \pi \alpha \frac{x}{y} x_{123} \beta

Explanation:

6 0
3 years ago
Read 2 more answers
Write an algorithm for a method (say is Descending) that accepts an integer arrays (say A) as input parameter, and returns a boo
Neko [114]

Answer:

Check the explanation

Explanation:

Algorithm for determining if the array passed as argument is in descending order or not.

1. Start

2. A = {1, 2, 3, 4};

3. Call function by passing array and it's size.

   isDescending(A, A.length);

4. Loop from 1 to size - 1 (inclusive)

5.     check if element at (i-1)th index is greater than element at (i)th index or not

6.     if at any point the above expression is executed to true value then return false

7.     if the above if statement is not executed then loop will terminate it self

8. Now return true.

// Java Implementation:

public static boolean isDescending(int[] arr, int size) {

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

       if (arr[i-1] > arr[i]) {

           return false;

       }

   }

   return true;

}

4 0
4 years ago
Select the correct answer.
Advocard [28]

Answer:

(B) because on a website IT HAS TO HAVE "WWW." first

4 0
3 years ago
Typefaces in this category share the common feature of small extensions, known as __________, which appear on the end of some of
Travka [436]

Answer:Sans Serifs

Explanation:

7 0
4 years ago
Read 2 more answers
Other questions:
  • Security testing attempts to verify that protection mechanisms built into a system protect it from improper penetration.
    9·1 answer
  • Discuss how the use of standard web component layouts and templates influences the visual design of a web page. In your opinion,
    9·1 answer
  • The __________ certification program has added a number of concentrations that can demonstrate advanced knowledge beyond the bas
    10·1 answer
  • Someone plzzzzz help me!!!
    6·1 answer
  • Momentous events in Philippine history where ICT played a huge role in making it a success?
    13·1 answer
  • Write a class called MagicSquare, which contains a single method called check that accepts a two-dimensional array as an argumen
    7·1 answer
  • B.
    12·1 answer
  • Tawni made some changes to her file and wants to save the changes in a document with a different title. How can she do this?
    14·2 answers
  • Which code segment results in "true" being returned if a number is even? Replace "MISSING CONDITION" with the correct code segme
    9·1 answer
  • when you enter a url, you’re creating a(n) ____ link, which is the full and complete address for the target document on the web.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!