Devuelve múltiples valores de una función usando punteros
#include <iostream>
using namespace std;
void maxAndMin(int num[], int size, int* max, int* min){
for(int i = 0; i < size; i++){
if(num[i] < *min)
*min = num[i];
if(num[i] > *max)
*max = num[i];
}
cout << "Minimum number is: "<< *min << endl;
cout << "Maximum number is: "<< *max << endl;
}
int main(){
int numbers[5];
for (int i = 0 ; i < 5 ; i++){
cout << "Number: ";
cin >> numbers[i];
}
int min = numbers[0];
int max = numbers[0];
maxAndMin(numbers, 5, &max, &min);
}
S.Y