• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Storing digits of an integer in an array

 
Greenhorn
Posts: 2
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Suppose I have a five digit integer.I wanted to break the integer and store its digits in an array.I am pasting the code upto which I'm done.Please let me know the solution.

 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Abhjit Banerjee wrote:Hi,
Suppose I have a five digit integer.I wanted to break the integer and store its digits in an array.I am pasting the code upto which I'm done.Please let me know the solution.




Looks like you done it. The only thing left is to store it into an array, instead of printing it out to standard output.

Henry
 
Abhjit Banerjee
Greenhorn
Posts: 2
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Henry,Thanks for replying so quickly.Actually you got it right,only storing these digits into the array is left.I'm not getting how to do it.

You can see from the code that remainders will be 5,4,3,2,1 respectively.I need to store this into an array to do some manipulation.Can you suggest something.

Abhijit
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What have you tried? Do you know how to declare an array, and how to access individual elements?

We really try to not hand out answers here, but will generally bend over backwards to help you figure it out. Show us what you've tried, tell us what it does, what it doesn't do, what you expect it to do, and how you know what it does.
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

A little hint which might help about arrays: you can never have an int with more than ten decimal digits in. Beware with % and negative values, however.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic