quick question but I can't find any solution to it. Basically the program below is suppose to square each integer from 1-1000. But when I print it, it cuts off. I can only print 300 lines and after that it cuts it off. For this example, instead of the first line being 1, it's 4, if it is j<301, and it will be 9 if j<302. How can I print 1000 lines is my main question.
#include <stdio.h>
#include <math.h>
int main(void)
{
int j;
double k,sarr[1000];
for (j=0; j<301; j++)
{
k = pow(j,2);
sarr[j] = k;
printf("\n%lf",sarr[j]);
}
return(0);
}
There's nothing wrong with your code. I suspect your terminal only keeps the last 300 lines of the program's output in its line buffer.
Try redirecting the output to a file (or writing the numbers to a file from within your program).