Hi Faisal,
I understand that you are trying to plot the Fourier series of a periodic signal.
The following resources on plotting signals and array indexing will help you in plotting the signal until two periods.
Hope it helps.
Regards,
Sai Pavan