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
How to do this PLEASE HELP 80 points!
sp2606 [1]

When reading the story, you know that the code has been created by humans, so it might actually be english and use concepts like our number system, our computer code system (I'm thinking ASCII), things that you should not assume when decoding a real alien message.

Looking at the numbers I notice that digits 6 to 9 do not occur in the message, which is statistically unexpected. This leads me to believe the number base might be 6 rather than our common base 10. In the story there are insects mentioned. Insects have 6 legs, so this makes sense (after all, our base 10 was based on the number of fingers).

Next, I notice the code 052 appearing regularly, so that could be a space. Let's check a hypothesis. 052 in base 6 is 5*6+2 = 32. 32 is the ASCII code for a space!!

Now, a decoding algorithm is ready to be devised:

"for each number in the sequence, parse it as a base-6 number and then print out its corresponding ASCII value".

The following node.js snippet does this:

var code = ['220','241','255','245','052','313',

           '311','052','312','303','052','312',

           '252','245','052','205','241','251',

           '253','243','052','203','253','302',

           '251','244','303','301','053'];

           

var msg = "";

for (let n of code) {

   msg += String.fromCharCode(parseInt(n,6));

}

console.log(msg);


And the message is.........:

<em>Take us to the Magic Kingdom!</em>

So, do these aliens want to visit Disneyland????

5 0
2 years ago
when a user has the requirement to stay connected 100% of the time as they move throughout the WLAN coverage area, what are they
zimovet [89]
They are concerned about many things
5 0
3 years ago
This operator represents the logical AND.
sdas [7]

Answer:

C. &&

Explanation:

Of the options provided:

A) ++ : increment operator. For example : ++1 = 2

B) || : Logical OR operator. A || B is true if any one of A or B is true.

C) && : Logical AND operator. A && B is true if both A and B are true.

A            B         A && B

False    False      False

False    True       False

True     False      False

True     True        True

D) @ : Ampersand character (commonly used in email addresses) e.g, [email protected]

3 0
2 years ago
What is a motherboard​
aleksandr82 [10.1K]

Answer:

A motherboard is the main printed circuit board in general-purpose computers and other expandable systems. It holds and allows communication between many of the crucial electronic components of a system

Explanation:

8 0
2 years ago
Malcolm Movers charges a base rate of $200 per move plus $150 per hour and $2 per mile. Write a program named MoveEstimator that
jeka94

Answer:

import java.util.Scanner;

public class MoveEstimator

{

public static void main(String[] args) {

   

    Scanner input = new Scanner(System.in);

    final int BASE_RATE = 200, RATE_PER_HOUR = 150, RATE_PER_MILE = 2;

    int hours, miles;

    double totalFee = 0.0;

   

 System.out.print("Enter the number of hours for a job: ");

 hours = input.nextInt();

 System.out.print("Enter the number of miles: ");

 miles = input.nextInt();

 

 totalFee = BASE_RATE + (hours * RATE_PER_HOUR) + (miles * RATE_PER_MILE);

 System.out.printf("For a move taking %d hours and going %d miles the estimate is $%.2f", hours, miles, totalFee);

}

}

Explanation:

*The code is in Java.

Create the Scanner object to be able to get input

Initialize the constant values using final keyword, BASE_RATE, RATE_PER_HOUR, RATE_PER_MILE

Declare the variables, hours, miles, totalFee

Ask the user to enter the hours and miles

Calculate the totalFee, add BASE_RATE, multiplication of  hours and RATE_PER_HOUR, multiplication of  miles and RATE_PER_MILE

Print the output as in required format

6 0
2 years ago
Other questions:
  • Due to the internal style sheets of some browsers, your website may look different to someone who is using firefox as opposed to
    11·1 answer
  • The ____ button resets slide placeholders to their default position, size, and text formatting.
    11·1 answer
  • You modify a document that is saved on your computer. Where are the changes stored until you save the document?a. Radom access m
    15·1 answer
  • What is WEB 1.0 to WEB3.0
    11·1 answer
  • What can act as a buffer against unemployment
    11·1 answer
  • The MAA is responsible on a daily basis to protect office computers and patient records and personal information from hackers. R
    12·1 answer
  • g Design a Boolean function called isPrime, that accepts an integer as an argument and returns True if the argument is a prime n
    14·1 answer
  • Implementations <br> in c++ programming when finding lcm and gcd in c++​
    12·1 answer
  • I need help fixing this please
    6·2 answers
  • Consumers who wish to make a purchase from other consumer on ebay need tl
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!