DC Motor Spinning at 360 degree

How to make DC motor to spin at 360 degree and then stop . Any code ?

Need a shaft encoder.

I would recommend a servo. What is your setup?

A normal DC motor will be very difficult to stop at exactly 360o, due to inertia, whatever method you use to detect when it has completed one revolution. I suggest you use a stepper motor.