# Thread: How to find the highest value

1. ## How to find the highest value

How can I find the highest value of 3 items?
Like:

WeaponVote1 = 2;
WeaponVote2 = 0;
WeaponVote3 = 1;
How can I find who is the highest easiest?

2. Use an array like this:
Code:
```something()
{
weaponVote = [];
weaponVote[0] = 2;
weaponVote[1] = 0;
weaponVote[2] = 1;
highest = getHighest(weaponVote); //This will make highest equal to 2
}

getHighest(array)
{
highest = array[0];
for(i = 0; i < array.size; i++)
if(array[i] > highest)
highest = array[i];
return highest;
}```

3. ## The Following User Says Thank You to master131 For This Useful Post:

Xray Hunter (09-27-2011)

4. Originally Posted by master131
Use an array like this:
Code:
```something()
{
weaponVote = [];
weaponVote[0] = 2;
weaponVote[1] = 0;
weaponVote[2] = 1;
highest = getHighest(weaponVote); //This will make highest equal to 2
}

getHighest(array)
{
highest = array[0];
for(i = 0; i < array.size; i++)
if(array[i] > highest)
highest = array[i];
return highest;
}```
I don't think that this will work for all three, try the calling function
Code:
```getHighest(array)
{
highest = array[0];
highest2 = array[2];
for(i = 0; i < array.size; i++)
if(array[i] > highest)
highest = array[i];
else if(array[i] > highest2)
array[i] = highest;
else
array[i] = highest;
return highest;
}```

5. Originally Posted by dsds1
I don't think that this will work for all three, try the calling function
Code:
```getHighest(array)
{
for(i = 0; i < array.size; i++)
if(array[i] > highest)
highest = array[i];
return highest;
}```
lol you just have to delete highest = array[0]
But I understand what he means

6. It WILL work, trust me. It would still work even if the 0th item was not the highest.