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

In the Mac terminal Write c++ function maxmin(float x, float * pmax, float * pmi

ID: 3743811 • Letter: I

Question

In the Mac terminal Write c++ 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 using namespace std; void maxmin(float x, float * pmax, float * pmin) { if(x > *pmax) { *pmax = x; } if(x < *pmin) { *pmin = x; } } int main() { float num; cin >> num; float min = num, max = num; while(cin >> 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