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
Explain 3 categories of plagiarism​
hammer [34]

Answer:

Direct plagiarism- the word-for-word transcription of a section of someone else’s work, without attribution and without quotation marks

Self-plagiarism- when a student submits his or her own previous work, or mixes parts of previous works, without permission from all professors involved

Mosaic Plagiarism- when a student borrows phrases from a source without using quotation marks, or finds synonyms for the author’s language while keeping to the same general structure and meaning of the original

8 0
3 years ago
Read 2 more answers
Analyze the error in the html code :<br><br> HTML
Andrei [34K]

Answer:

The World Wide Web Consortium provide a simple online tool (https://validator.w3.org/) that automatically check your HTML code and point out any problems/errors your code might have, such as missing closing tags or missing quotes around attributes.

Explanation:

your question is not clear

hope it helps

6 0
3 years ago
he Saffir-Simpson Hurricane Scale classifies hurricanes into five categories numbered 1 through 5. Write an application named Hu
AnnyKZ [126]

Answer:

The program plan requires the design of the gui program form

Explanation:

The program plan will be as follows:

take 4 label and 4 text box and 1 button and modify the property of controls to design the gui form.

use 6 if statements and 1 else statement.

use or operator for comparison.

show message in textbox.

program code:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System. Data;

using System.Drawing;

using System.LINQ;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

namespace...

4 0
3 years ago
Read 2 more answers
What type of malicious software tries to gather information about you without your consent?
AlekseyPX

Answer:

B-malware

Explanation:

I do tech and i help work on computars.

6 0
3 years ago
(01.01 LC)
zloy xaker [14]

Answer:

Create web and mobile applacations

Explanation:

6 0
3 years ago
Other questions:
  • Write a Tip Calculator in code in VMware Fusion
    13·1 answer
  • Given a floating point variable fraction, write a statement that displays the value of fraction on the screen. Do not display an
    13·1 answer
  • The negotiators past relationship will affect current behavior if the parties
    12·1 answer
  • In gaming, "rendering" refers to:
    12·2 answers
  • : How does the founder of Wikipedia keep a tight reign on accuracy? HELP PLEZ AT LEAST A PARGRAPH PLES
    6·1 answer
  • I NEED IT FOR TODAY FOR KEYBOARDING TEST! GIVE ME CORRECT ANSWER PLZ!
    12·2 answers
  • DES: Group of answer choices A) is a commonly used symmetric encryption B) algorithm that was developed in the mid-C) 1970s was
    6·1 answer
  • JUST MAXED OUT THE COMMENTS anyways come here
    7·2 answers
  • Code Problem 3 in Python 2.
    5·1 answer
  • Unscramble the given word and identify the correct statement about it. ATTEPLSR
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!