array from 0 to 1 with 1000 elements

I am trying to make an array from 0 to 1 with 1000 elements. What i have makes an endless string of 0,s in the terminal window. It has been a while since i used c++, and i dont know what im doing wrong, can someone please help???

1
2
3
4
5
6
7
8
  	int i;
	int time [1001];
	for (i=0;1<=1001;i++)
	{
	time[i] = i/1000;
	cout << time[i] << endl;
	}
Last edited on
int is short for integer. You want a real number type like double. Also make sure you divide by 1000.0 and not 1000
Last edited on
Since time is holding integer values you will only get the integer part of the division. so anything below 1000 will be 0, 1000 will be 1.
Topic archived. No new replies allowed.