# beginner

Show 80 post(s) from this thread on one page
Page 2 of 2 First 12
• 06-09-2004
if you want the numbers 1-10 in the array and you don't want to do it this way

int array[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

you can do it this way

for (i=0, i<10, i++)
{
list[j] = i;
};

but the latter will put the numbers 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 in your array. To get 1-10 in the array using the latter format you can change the value of i so it ranges from 1 and <= 10 or from 1 to < 11. Or you can leave the range of i as you have it and change the value assigned to list[j] by always adding 1 to i before the assignment.
• 06-09-2004
jennilla
excactly, should it be list[i] = i;?
• 06-09-2004
jennilla
Thank you all, everything is right now. tomorrow I will be back with new assignment and new questions :)
• 06-09-2004
Prelude
>excactly, should it be list[i] = i;?
Yes. And you should be careful with i and j as identifiers. They look strikingly similar in certain commonly used fonts. :)
• 06-10-2004
big146
Hmmm, I havent seen this yet, any reason why ?
Code:

```int _tmain(int argc, _TCHAR* argv[]) {         for ( int i = 1; i < 11; i++ ) {                 if( i % 2 == 0)                         continue;                 cout << i << endl;         }         return 0; }```
Is this not a good practice ?
He did not say how this was to be done, so I would think this would be the simplest way to do it for a beginner.
• 06-11-2004
Prelude
>I havent seen this yet, any reason why ?
Seen what? Modulus to determine even and odd?

>int _tmain(int argc, _TCHAR* argv[])
Seeing as how _tmain isn't the standard entry point into a C++ program, and you don't use the arguments that you declare (and barring any funky requirements for you outside of this forum), it should be this:
Code:

`int main()`
;)

>Is this not a good practice ?
I don't see any problem, stylistically, with the algorithm.
• 06-11-2004
big146
Thx for the reply. But what I meant was since he only had to have the program list number 1 thru 10 and then output the odd ones. Why something like the code I posted was not used? It seems simple enough for someone starting out.He didnt specify how to get the numbers just that he had too,that is all.Aslo i just let visual studio genrate the app for me..I was feeling to lazy to add a cpp.But normaly i do add my own with int main().

thks
big146
• 06-12-2004
Prelude
>Why something like the code I posted was not used?
Because the original question was how to write 10 numbers to a list and then remove the odd numbers. That suggests saving intermediate values (as in an array) rather than the test and print solution you posted.
Show 80 post(s) from this thread on one page
Page 2 of 2 First 12