Not connected to computer

If you put a program on an arduino, how do you get it to run when it is not plugged into the computer?

bradwiggo:
If you put a program on an arduino, how do you get it to run when it is not plugged into the computer?

You connect a DC power supply or battery, between 7V and 12V, to the DC socket or Vin connection.
Or a regulated 5V supply to the 5V connection.

I've seen a couple of questions like this. To add to OldSteve's reply:

It might not directly be clear but when you upload a compiled sketch to the Arduino, it is stored in the micocontroller's flash memory and will not be lost when you disconnect the computer (and hence loose the power).

Will it just start as soon as the arduino is powered?

Yes. All the code in void setup() wil run once first. The all the code in void loop() will run forever.

dorvakta: Yes. All the code in void setup() wil run once first. The all the code in void loop() will run forever.

Thank you for your reply

What about if it's an arduino with an atmega32u4?

It's the same for all arduinos. Check the documentation on the arduino page.