Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help! Turing
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
nelsonkkyy




PostPosted: 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
Sponsor
sponsor
nelsonkkyy




PostPosted: Thu Oct 22, 2009 2:48 pm   Post subject: RE:Help! Turing

Someone help me?
SNIPERDUDE




PostPosted: 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.
nelsonkkyy




PostPosted: Thu Oct 22, 2009 3:55 pm   Post subject: RE:Help! Turing

so how do write in array?
SNIPERDUDE




PostPosted: Thu Oct 22, 2009 5:13 pm   Post subject: Re: Help! Turing

The Turing Walkthrough should have any topic you wish to explore.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: