GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 15-Feb-2004, 12:59
amir_b amir_b is offline
New Member
 
Join Date: Feb 2004
Posts: 27
amir_b is on a distinguished road

Breaking the number into two digits


Hello!

I would like to know how to break the number into two digits. For example, if I enter number 45 it should print "You entered number forty five." I would like to do it with switch statement.

If anybody could help I would appreciate that.

Thanks.
  #2  
Old 15-Feb-2004, 13:16
dsmith's Avatar
dsmith dsmith is offline
Senior Member
 
Join Date: Jan 2004
Location: Utah, USA
Posts: 1,351
dsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of light
Hello Amir.

Here are a couple threads that you should take a look at, especially the last one.

Integer splitting
C help

I think these should give you a pretty good start on what you want to do.

Good luck!
  #3  
Old 15-Feb-2004, 16:22
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,243
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
Quote:
Originally Posted by amir_b
Hello!

I would like to know how to break the number into two digits. For example, if I enter number 45 it should print "You entered number forty five." I would like to do it with switch statement.

If anybody could help I would appreciate that.

Thanks.
The easiest way to handle this is to use the mod operator % which is related to the / operator:


x = 536 % 10; // x gets the remainder of 6
y = 536 / 10; // y gets the value 53
  #4  
Old 16-Feb-2004, 12:28
aaroncohn's Avatar
aaroncohn aaroncohn is offline
Regular Member
 
Join Date: Feb 2004
Location: Bay Area, CA.
Posts: 564
aaroncohn is a jewel in the roughaaroncohn is a jewel in the roughaaroncohn is a jewel in the rough
Quote:
Originally Posted by WaltP
The easiest way to handle this is to use the mod operator % which is related to the / operator:


x = 536 % 10; // x gets the remainder of 6
y = 536 / 10; // y gets the value 53

Just make sure you're using int math
 
 

Recent GIDBlogMeeting the local Iraqis by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
c: array comparison jack C Programming Language 7 26-Jan-2004 11:21
Random() : Make each number onlu appear once NiXeN C++ Forum 3 13-Jan-2004 04:47
How to find the last 6 digits of a 8 digit number? rjd72285 C++ Forum 3 28-Oct-2003 08:21
Displaying the Post Number BobbyDouglas Open Discussion Forum 4 10-Oct-2003 10:43
auto number skyloon MySQL / PHP Forum 1 30-Jun-2003 08:33

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 11:20.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.