int main()
{
printf ("power is currently on");
}
Coding the "power is currently off" case is somewhat trickier.
Alternately if you want to know the time since the last boot, and put up a message if it was recent, then see Uptime under linux in C