With problems like this, more information than you've provided is generally helpful.
--What version of iOS is it running?
--Have you updated the firmware since you got it?
--Did you set it up as new, or from a backup?
--Is this a new problem, or has it done this from the day you got it?
--How much space remains available? Is it full?
--Have you powered it off and on lately rather than just waking it from sleep? (Hold power button until slider appears, the slide to power off.) Tried a hard reset? (Hold power + home buttons until the device reboots.)
Without more information, all I can tell you is it's generally software rather than hardware unless it starts flashing a solid color screen--often blue, sometimes red or green--at you before it reboots. (That would be a big sign that you need to take it to Apple.)
Assuming it's software, I'd try a hard reset before anything else. If you're out of storage, try removing about a quarter of what you have on it. If neither of these work, you may need to wipe it clean and preferably set it up as new, not from backup.