First, check that the power cord is in securely and hasn't come loose.
If it's not a loose power cord you might want to try resetting the SMU:
- Turn off the computer by choosing Shut Down from the Apple menu, or by holding the power button until the computer turns off.
- Unplug all cables from the computer, including the power cord.
- Wait 10 seconds.
- Plug in the power cord while simultaneously pressing and holding the power button on the back of the computer.
- Let go of the power button.
- Press the power button once more to start up your iMac.
My rev B iMac G5 started randomly shutting down a few months ago and eventually stopped working - I couldn't power it back on at all. I just got it back today, it's had a new logic board and power supply fitted.
I would strongly suggest that you back up your system ASAP in case this happens again and won't power back on. If it does happen again, then yes, I'd suggest you take it in to the Genius Bar (assuming it's still under warranty?)