It's all about filesystem flags, and you only to ensure that:
The executable file does belongs to root
It has the suid flag in the file system (you can set it with chattr u+s).
After you'll do that, it will be executed with root permissions even when running from a regular user.
Please also note that you can get an UID which had actually ran the program by calling getuid(), while geteuid() will always evaluate to 0.