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

Username:   Password: 
 RegisterRegister   
 Checking individual digits in an integer
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
lemoe




PostPosted: Tue Feb 07, 2012 9:03 pm   Post subject: Checking individual digits in an integer

My Problem is...
I have to write a program that checks whether a number is the same when rotated 180 degrees. I don't need help with the coding, I would just like some assistance with understanding a command to do this. Is there a command that checks the character or digit at a specified location in an integer? eg.) What is the third digit of integer 1863? Thanks in advance.

I am using Turing 4.0.5.
Sponsor
Sponsor
Sponsor
sponsor
mirhagk




PostPosted: Tue Feb 07, 2012 9:20 pm   Post subject: RE:Checking individual digits in an integer

Well an easy way would be turning it into a string, and then indexing the string.
crossley7




PostPosted: Tue Feb 07, 2012 10:47 pm   Post subject: RE:Checking individual digits in an integer

a way to do it without converting to a string is integer division then mod by 10. Look up the commands div and mod and think about how exactly you could do that
lemoe




PostPosted: Wed Feb 08, 2012 7:37 am   Post subject: RE:Checking individual digits in an integer

Thanks
mirhagk




PostPosted: Wed Feb 08, 2012 10:22 am   Post subject: RE:Checking individual digits in an integer

crossley's way it probably the better one, but just wanted to let you know there was multiple ways.
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: