Why does void loop() stop after some samples?
float sine[5000]
...
sine[j]=s+190;    



A float takes 4 bytes. You are allocating 5000 of them which is 20000 bytes. The Uno has 2048 bytes of RAM. Thus you are running out of RAM and overwriting something you shouldn't be.



As pointed out on the Arduino forum, your for loop which tests for:

i &lt; sample2 || i &gt;= sample2


will always be true. Of course i will be either less than or greater than or equal to sample2.