Search code examples
c++variablesc++11max

How to find the maximum value's variable name?


int a = 1;
int b = 2;
int c = 3;
int d = 4;

How would I find out if the maximum integer value is stored in variable d?


Solution

  • You need to use an array instead of these variables, then you will easily find max element. See the example here