ports in and outputs

hi there. i want to wire up a and gate on my arduino, what i was wonder was how can i tell one put to give out power when another port receives power. say if i press a button and this gives power to port 4, then when port 4 gets power i want it to tell port 5 to give out power to work another switch. how do i wright this as a code? thanks

The digitalRead() and digitalWrite() methods look interesting.