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
Which of the following are true statements about the data that can be represented using binary sequences?
g100num [7]

Answer:

All of the above.

Explanation:

In Computer science, a bit is a short word for the term binary digit and it's primarily the basic (smallest) unit measurement of data or information.

A bit is a logical state which represents a single binary value of either one (1) or zero (0). This ultimately implies that, a single bit in computer science represents a boolean value of;

  • True or ON, which is equal to one (1).
  • False or OFF, which is equal to zero (0).

Therefore, a bit that is turned off represents the value of binary numbering because it has a numerical value of zero (0).

A binary sequence represents all binary digits that are to be written in sequences of ones (1s) and zeroes (0s). Hence, a binary sequence can be used to encode data such as sound (audio) strings of characters, video, images, colors, computer instruction codes etc.

<em>The true statements about the data that can be represented using binary sequences are;</em>

1. Binary sequences can be used to represent strings of characters.

2. Binary sequences can be used to represent colors.

3. Binary sequences can be used to represent audio recordings.

6 0
4 years ago
Write a program to read 2 numbers and display the largest of the two. You should use scanfto read the two numbers and use if sta
Harman [31]

Answer: in C

#include <stdio.h>

int main(){

  int num1, num2;

  printf("Enter first number :: ");

  scanf("%d", &num1);

  printf("Enter second number :: ");

  scanf("%d", &num2);

 

  if(num1 > num2){

     printf("%d is larger than %d\n", num1, num2);

  } else if (num2 > num1) {

     printf("%d is larger than %d\n", num2, num1);

  } else{

     printf("Both of them are equal\n");

  }

  return 0;

}

8 0
4 years ago
Figuring out why your computer won't turn on falls under diagnosing.<br> A. True<br> B. False
igomit [66]
The answer to your question, is true
hope this helps :D
7 0
3 years ago
Read 2 more answers
Write the function setKthDigit(n, k, d) that takes three integers -- n, k, and d -- where n is a possibly-negative int, k is a n
liq [111]

Answer:

Explanation:

Let's do this in Python, first we need to convert the number into string in order to break it into a list of character, then we can replace the kth character with d. Finally we join all characters together, convert it to integer then output it

def setKthDigit(n, k, d):

n_string = str(n)

d_char = str(d)

n_char = [c for c in n_string]

n_char[k] = d_char

new_n_string = ''.join(n_char)

return int(new_n_string)

6 0
4 years ago
Which function key will help you find the word and replace
MaRussiya [10]

F5 key on your keyboard in word and power point if that is what you are referring to.


3 0
3 years ago
Other questions:
  • SubVIs...
    15·1 answer
  • Chandra, a student working on a group project, is trying to decide how to have the whole group suggest revisions for an essay. S
    10·1 answer
  • âthe first line in a hypertext markup language (html) file is the _____, which is a processing instruction indicating the markup
    9·2 answers
  • As a digital forensics examiner, it’s a good idea to build a list of references for information on privacy laws in other countri
    13·1 answer
  • What is pure carbon made of
    14·2 answers
  • Agent Phil Coulson developed this program to register Avengers in S.H.I.E.L.D's database using cutting-edge programming language
    15·1 answer
  • To cope with the uncertainty about how their pages will be viewed, many web page designers opt to use _________ units, which are
    13·1 answer
  • JAVA
    9·1 answer
  • When the narrator of "EPIC 2015" describes the year 2015 as the "worst of
    6·1 answer
  • What is the advantage of learning through story compared to learning through personal experience?
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!