i want to know how can i find the maximum and minimum value in c++ by user input value and and user also put the limit for for loop , for example :
Write a c++ prog
int input; int max = 0; int min = 0; cout << "Enter number: "; while (input != -1) { cin >> input; if(input != -1) { if(input > max) { max = input; } if(input < min) { min = input; } } } cout <<"Max: " << max << " Min " << min << endl;
}