Well first off C doesn't have booleans, and using 0 and 1 instead would still create some logical issues.
Once both are found, what happens to the WATR and SAND? We have no idea where the first particle is, just that it existed. You would need to store the particle number for both types, then delete those particles when they both exist. Resetting the variables would do nothing, since after the loop is done, they aren't used...