Answer to Question #208232 in C++ for Binura Thiranjaya

Question #208232

Write the program using C++


Note: Use the mode to call the functions and store values in the array (value3).


(g) Function Name-PrintReport() which takes two float values and int size as parameters. .


Note: Should use StoreData function already defined to find min, max, total and avg marks.


(h) Create a structure with the fields; subject name, total and avg.


(i) Implement the main method of a C++ program,


Create float arrays with the names subject l , subject 2 and results. The arrays are of size 5.Find and print the highest marks,Lowest,Total,avg of Subject P and Subject Q of each class using the function StoreData().Print the report using the function PrintReport().


Create two structure variables. Each variable should store and print a summary of each Subject, aggregating marks of all 5 classes.


1
Expert's answer
2021-06-18T02:54:52-0400
#include <iostream>

struct subject {
  std::string subjName;
  double total;
  double avjMarks;
};

void printReport(float val1, float val2, int size) {
  // implementation...
}

int main() 
{
  float subject1[5], subject2[5], results[5];

  std::cout << "min subject1: " << *min_element(subject1, subject1 + 5) << std::endl;
  std::cout << "max subject1: " << *max_element(subject1, subject1 + 5) << std::endl;
  float sum1 = std::accummulate(subject1, subject1 + 5, 0);
  std::cout << "total subject1: " << sum1 << std::endl;
  std::cout << "avg subject1: " << sum1 / 5 << std::endl;

  std::cout << "min subject2: " << *min_element(subject2, subject2 + 5) << std::endl;
  std::cout << "max subject2: " << *max_element(subject2, subject2 + 5) << std::endl;
  float sum2 = std::accummulate(subject2, subject2 + 5, 0);
  std::cout << "total subject2: " << sum2 << std::endl;
  std::cout << "avg subject2: " << sum2 / 5 << std::endl;

  printReport();
  
  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS