Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In C++, Write a function maxmin(float x, float * pmax, float * pmin) where x is

ID: 3742155 • Letter: I

Question

In C++, Write a function maxmin(float x, float * pmax, float * pmin) where x is a new value which is to be compared with the largest and the smallest values pointed to by pmax and pmin, respectively. The function should indirectly update the largest and the smallest values appropriately. Write a program that reads a sequence of numbers and uses the above function to update the maximum and the minimum until end of file, when the maximum and the minimum should be printed.

Explanation / Answer

#include #include #include using namespace std; void maxmin(float x, float * pmax, float * pmin) { if(x > *pmax) { *pmax = x; } if(x < *pmin) { *pmin = x; } } int main() { string filename; cout > filename; ifstream in(filename.c_str()); if(in.is_open()) { float num; in >> num; float min = num, max = num; while(in >> num) { maxmin(num, &max, &min); } cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote