QUOTE
hmmm.. i mean if i were to connect a switch to a microchip how could i possible check whether it works by C statement??
I do not know what type of microchip you are using, so I can't really go into any code.
Generally, you would have the power going to one end of the switch, the other end of the switch would be attached to one of the ports. Another port would be attached to the trigger of the switch. You would set the port attached to the trigger to send out a signal, which will cause the switch to activate, assuming it is working. From here, you would have to check the port that is attached to the second part that the switch bridged. If there is power on that pin, then it does work.
Since switches are no instant, you will have to add some type of delay, and actually give the pin a grace period. A pin interrupt might work, but again, I don't know what chip you are using.