1

In this code, what does the "? arr[ i ] : min;" mean? Specifically the question marks in the statements?

int min;
int max = 4000;

min = max = arr[0];
for(i = 1; i < sz; i++) {
    min = (arr[i] < min) ? arr[i] : min;
    max = (arr[i] > max) ? arr[i] : max;
}
S. James
  • 77
  • 5
  • 1
    Experiment! Try it yourself! For example, print the output of e.g. `1 < 2 ? 3 : 4` and `1 > 2 ? 3 : 4` and see what you get. Or why not simple use a debugger and step through the code you have line by line and see what happens? – Some programmer dude Nov 05 '15 at 04:12
  • Or use Google. Search "C++ Operators" or "C++ Question Mark". –  Nov 05 '15 at 05:36

0 Answers0