Compare two analog input signals

I have two analog inputs on A0 and A1. Both are on scales from 0-5000 (0-5 volts). A1 is connected to a variable resistor which is set at a certain value. A0 changes based on the environment. What I want to do is output a digital signal to turn on an alarm when A0's is greater than or equal to the value of A1 but have the alarm stay off when the value of A0 is less that A1. HELP.

Please don't cross-post.

I think an if statement would work.

if(A0>=A1)
//set output pin high