Help! Turing
Author |
Message |
nelsonkkyy
|
Posted: Thu Oct 22, 2009 9:39 am Post subject: Help! Turing |
|
|
Write a Turing program that will store intergers in an array until -99999 is entered. The program will then display all of the odd numbers entered and calculate the average of the odd numbers. Use strintok to ensure that the user enters only integers.
Can Someone help me?? I have no idea to make the odd number and sum and average. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
nelsonkkyy
|
Posted: Thu Oct 22, 2009 2:48 pm Post subject: RE:Help! Turing |
|
|
Someone help me? |
|
|
|
|
|
SNIPERDUDE
|
Posted: Thu Oct 22, 2009 3:33 pm Post subject: Re: Help! Turing |
|
|
First of all, please don't double post.
Second, for odd numbers you will want to look at the mod function (which gives you the remainder of anything divided.
So for example:
will give you 1
will give you 0, etc.
When you want to find out if a number is odd, you would mod the number by two. If it results in 0, it is even. Resulting in one means the number is odd. |
|
|
|
|
|
nelsonkkyy
|
Posted: Thu Oct 22, 2009 3:55 pm Post subject: RE:Help! Turing |
|
|
so how do write in array? |
|
|
|
|
|
SNIPERDUDE
|
Posted: Thu Oct 22, 2009 5:13 pm Post subject: Re: Help! Turing |
|
|
The Turing Walkthrough should have any topic you wish to explore. |
|
|
|
|
|
|
|