If you press the iMac power button while you are connecting the power cord, the iMac will enter a mode in which the fans run at full speed. In order to correct the issue, reset the SMC. Your iMac should now start up and operate as expected.
To avoid this issue, be sure to start the computer by pressing the power button after you fully connect the power cord.