Computer Science Canada

Help! Turing

Author:  nelsonkkyy [ 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.

Author:  nelsonkkyy [ Thu Oct 22, 2009 2:48 pm ]
Post subject:  RE:Help! Turing

Someone help me?

Author:  SNIPERDUDE [ 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:
Turing:
5 mod 2

will give you 1
Turing:
10 mod 2

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.

Author:  nelsonkkyy [ Thu Oct 22, 2009 3:55 pm ]
Post subject:  RE:Help! Turing

so how do write in array?

Author:  SNIPERDUDE [ Thu Oct 22, 2009 5:13 pm ]
Post subject:  Re: Help! Turing

The Turing Walkthrough should have any topic you wish to explore.


: