you should acquire an interval to be sure that one complete period of signal is selected, for example 1 second of signal(1000 sample) or 2 seconds, and apply FFT and easily find phase and magnitude you are looking for.
The very first problem is the function you wrote is not periodic, because it's not time dependent. It should be
x(t)=220.cos(2.pi.60.t+pi/5)
Where 60 is the signal frequency. I agree with Hossein that the sample is not needed to be one cycle, but if you want it, you need to take a time interval like
Serna Sir when i perform FFT on 960 samples then it give me correct magnitude and phase , but when i use only sixteen samples keeping the interval 1/960 than i get magnitude of 182 instead of 220 and .353 degree phase instead off 36.
could you tell me what im doing wrong actually i want to find phasor of the input signal
Your question is interesting. DFT is an improper name for the Fourier filter because DFT (or FFT) is defined not as the calculation of the Fourier coefficient, but as:
For length N input vector x, the DFT is a length N vector X,
I made some little changes in your code. It seems the inaccuracy calculating the phase is due to the small number of samples (and the small time window). If you change the sampling frequency (keeping the time interval at 1 cycle of the signal) you get: