• 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

program on array

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
program to display numbers in three different arrays(Even, Odd, and Prime numbers.) where each array would have unique numbers. The numbers should not overlap in arrays. Program should take a positive integer argument and print as shown below.


if the input is 10
I would like to see 3 arrays printed out in following manner

Prime Numbers : 2,3,5,7
Even Numbers : 4,6,8,10
Odd Numbers : 1,9

please help me out...as soon as possible
 
Ranch Hand
Posts: 440
Hibernate Eclipse IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Greetings Veera and welcome to the Ranch

This site is not a code mil and no-one will provide you with direct code solution. We would like you to do some re-search on your own and try to solve the problem , we will surely help you along the way.
So first I would like you to start with a pencil and a piece of paper and try to sort out the possible logic and come up with the algorithm . Then if you face any issue or you would like any opinion , we will surely help you out.

Do post back for any further queries
 
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
break down the problem into little pieces. Get one piece to work before you try the next. So, perhaps at first, you should figure out how to get the input of 10. Once you can do that, figure out how to look at every number (i.e. at first, just print it).

Then figure out how to add a number to an array.

Then figure out how to tell if a number is even.

Then figure out how to tell if a number is odd.


and so on. You should note that every task listed above can be done 100% independently from all the others. That is a key piece of programming - separate out individual tasks.
 
reply
    Bookmark Topic Watch Topic
  • New Topic