CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Code to break 4 digit number into its 4 digits?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
edbfmi1
Guest







Code to break 4 digit number into its 4 digits?
PostPosted: Mon Jul 17, 2006 3:04 pm     Reply with quote

Does anyone have an easy way to break a four digit number into its respective digits?

example:

convert a variable: value=1234

into four variables:
lsd = 4
lsd_1 = 3
lsd_2 = 2
msd = 1

Thanks
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

View user's profile Send private message Send e-mail

PostPosted: Mon Jul 17, 2006 3:09 pm     Reply with quote

Search a little bit on the forum. This sort of thing was just discussed.

Key things are the modulus operator.

http://www.ccsinfo.com/forum/viewtopic.php?t=27600

Hope this helps you get hour homework done... Cool
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Jul 17, 2006 4:20 pm     Reply with quote

Funny to see how these students always log in as guest. Do they suspect their teacher is monitoring this forum? Cool
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group