- #1
sandy.bridge
- 798
- 1
Hey guys. I just want to see if I am indeed "seeing" the significance of the code that is to follow. I will follow it with a brief explanation of what I thought the code did. Thanks in advance.
This program scans through the program in accordance to properties exhibited by the integer value i. If the element in the array had a property being tracked, then it was assigned Boolean true. If it was not, then it was assigned Boolean false. This program demonstrates how one can scan through an array, pursuing a particular property, and henceforth convey which elements within that array had that property.
PHP:
const int N = 15;
bool table[N];
int i = 0;
while (i < N)
{
table[i] = true;
i = i + 1;
}
table[0] = false;
i = 2;
while (i < N)
{
if (table[i])
{
int j = 2*i;
while (j < N)
{
table[j] = false;
j = j + i;
}
}
i = i + 1;
}
i = 0;
while (i < N)
{
if (table[i])
{
cout << i << " ";
}
i = i + 1;
}
cout << endl;
This program scans through the program in accordance to properties exhibited by the integer value i. If the element in the array had a property being tracked, then it was assigned Boolean true. If it was not, then it was assigned Boolean false. This program demonstrates how one can scan through an array, pursuing a particular property, and henceforth convey which elements within that array had that property.