Warning

 

Close

Confirm Action

Are you sure you wish to do this?

Confirm Cancel
BCM
User Panel

Posted: 10/10/2005 3:49:09 PM EDT
Write a program that inputs a five digit integer, seperates the integer into its individual digits seperated by three spaces each they give a hint[use the integer division and modulus operators .

for example type int 42339 then it should print 4   2   3   3   9

I need to learn how to seperate an integer number. how do you seperate an integer?

is it possible to seperate a single integer!
Link Posted: 10/10/2005 9:36:08 PM EDT
[#1]
Do I look like a homework bitch?

I'd convert it to a char array and print them out that way.. adding the spaces is easy then.

Go look at the source coide for printf()  that function has to do type int to type char[] conversion.
Link Posted: 10/10/2005 10:06:36 PM EDT
[#2]

Quoted:
Write a program that inputs a five digit integer, seperates the integer into its individual digits seperated by three spaces each they give a hint[use the integer division and modulus operators .

for example type int 42339 then it should print 4   2   3   3   9

I need to learn how to seperate an integer number. how do you seperate an integer?


No you can not seperate an integer.


is it possible to seperate a single integer!




No. Follow NimmerMehr's advice and convert the Int to a String


Strings are infinitly more easy to manipulate then any other data type.
Link Posted: 10/10/2005 10:12:36 PM EDT
[#3]
they specifically wanted it done using a integer!!!
Link Posted: 10/11/2005 9:43:41 AM EDT
[#4]

Quoted:
they specifically wanted it done using a integer!!!



use division and strip the remainder



42339

divied by 10000 you get 4.2339
strip the .2339

then subtract (4 * 10000) from 42339
you get 2339
divied by 1000, you get 2.339
strip the .339

repeat untill your at base unit position


and this isn't a c++ quiestion, the is basic programming. peroid.

and i have to master basic spelling.
Link Posted: 10/11/2005 2:35:01 PM EDT
[#5]

Quoted:
they specifically wanted it done using a integer!!!



the hard way:
convert it to a char array, type cast each char to an int, then output each int.
Link Posted: 10/11/2005 2:43:48 PM EDT
[#6]

Quoted:
this isn't a c++ quiestion, the is basic programming. peroid.



Using the modulus operator:

x=42339;
a=x % 10;
x=x/10;
loop til 0

If you're having problems with this, you need to change what you're getting into. This is a "freshman simple" problem.
Link Posted: 10/11/2005 2:53:03 PM EDT
[#7]
no what there wanting is to take 42339 seperate the 4    2    3    3    9  4<3spaces>2<3spaces>3<3spaces>3<3spaces> etc! Etc!
i can easly take individual integers and seperating them!

the end result is to print 42339 seperatly.
Link Posted: 10/11/2005 2:58:44 PM EDT
[#8]

Quoted:
no what there wanting is to take 42339 seperate the 4    2    3    3    9  4<3spaces>2<3spaces>3<3spaces>3<3spaces> etc! Etc!
i can easly take individual integers and seperating them!

the end result is to print 42339 seperatly.



To me that is the hardest part, so i don't see what your problem is anymore.
Link Posted: 10/11/2005 3:09:55 PM EDT
[#9]
You can lead a horse to water...
Link Posted: 10/11/2005 3:14:26 PM EDT
[#10]
btt
Link Posted: 10/12/2005 3:57:46 PM EDT
[#11]

Quoted:

Quoted:
no what there wanting is to take 42339 seperate the 4    2    3    3    9  4<3spaces>2<3spaces>3<3spaces>3<3spaces> etc! Etc!
i can easly take individual integers and seperating them!

the end result is to print 42339 seperatly.



To me that is the hardest part, so i don't see what your problem is anymore.



me neither
Link Posted: 10/12/2005 4:43:55 PM EDT
[#12]

Quoted:

Quoted:
no what there wanting is to take 42339 seperate the 4    2    3    3    9  4<3spaces>2<3spaces>3<3spaces>3<3spaces> etc! Etc!
i can easly take individual integers and seperating them!

the end result is to print 42339 seperatly.



To me that is the hardest part, so i don't see what your problem is anymore.



I'm guessing he's having a problem seperating the 4 from the 2 from the 3 from the 3 from the 9?

If thats the problem, he probably needs to pay more attention to the thread.
Link Posted: 10/12/2005 6:34:04 PM EDT
[#13]
I was going back through some basic programming skills and doing the excercises! I just had a problem with  this one question! the text does not show an example on how to seperate an single integer. all i ask was for some help on this, not harrassment on how stupid i am!  
Link Posted: 10/13/2005 6:36:10 AM EDT
[#14]

Quoted:
I was going back through some basic programming skills and doing the excercises! I just had a problem with  this one question! the text does not show an example on how to seperate an single integer. all i ask was for some help on this, not harrassment on how stupid i am!  



You said you already know how to seperate the number into inidividual integers, and not you say you can not.  which is it?

As for the stupid part: This is the Internet. There are millions of people with nothing better to do but belittle others.
Close Join Our Mail List to Stay Up To Date! Win a FREE Membership!

Sign up for the ARFCOM weekly newsletter and be entered to win a free ARFCOM membership. One new winner* is announced every week!

You will receive an email every Friday morning featuring the latest chatter from the hottest topics, breaking news surrounding legislation, as well as exclusive deals only available to ARFCOM email subscribers.


By signing up you agree to our User Agreement. *Must have a registered ARFCOM account to win.
Top Top