It's normal for a phone to get warm when active (e.g., playing a game, taking lots of photos, installing a bunch of apps). It can also get warm if your cell signal is poor, since the phone has to work harder at maintaining the signal. 40C is not unusual.