By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,148 Members | 1,242 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,148 IT Pros & Developers. It's quick & easy.

arrays

P: 1
Greetings All,

my knowledge in arrays is very slim. My knowledge in c++ is slim for the mere fact that this is my first time using it.

I have this problem and do not know how to start it....

any suggestions are most welcome

Use a one-dimensional array to solve the following problem. Read in 20 numbers, each of which is between 10 and 100, inclusive. As each number is read, validate it and store it in the array only if it is not a duplicate of a number already read. After reading all the values, display only the unique values that the user entered. Provide for the “worst case” in which all 20 numbers are different. Use the smallest possible array to solve this problem.
Mar 22 '07 #1
Share this Question
Share on Google+
2 Replies


sicarie
Expert Mod 2.5K+
P: 4,677
Per our Posting Guidelines

Posting Homework or Coursework Questions and Answers
This site is not a place where you can get your homework and course work done for you. Ignoring the questionable morals of getting someone else to do your work towards a formal qualification you will learn a lot more by attempting the problem yourself, then asking for help with the bits that are not working. You will be more likely to get help if you appear to have made an attempt at the problem yourself.

* If it appears that the question has just been pasted directly from a text book or coursework assignment our moderators have been instructed to meet this with a set response. This is a pre-written message asking you to make some attempt at the assignment yourself before asking questions about specific problems and referring you to this FAQ.
* Do NOT post your complete source code. Remember, you found this site, so can your professors and tutors and they are likely to take a dim view if you hand in something that appears to be copied from this site. In most academic institutes the minimum response to copying of assignments is a 0 mark for the assignment in question. If you post your entire code your professor will not know it was your work, you may be penalised for copying from yourself.
* If an expert requests that you provide more of your code then you can PM it to them, however please do not PM them your code unless requested.
* Acceptable questions that students can ask are on functionality and theory or syntax corrections in small posted code snippets.
* Please make sure you have asked an actual question worded in English outside of the text of your assignment that you have posted.
What have you tried? Can you post the relevant code? What error messages are you getting? What google searches have you tried?
Mar 22 '07 #2

Roonie
P: 99
well, it looks like youre going to be using an array to store your data.

the specs say that you should provide storage for 20 elements . . . it also says to make the array as small as possible given the specs . . . how long do you think the array should be to store 20 elements and no more?

after that, you should figure out a way to take input data and store it in your array . . . it looks like you are supposed to perform input-data checks before storing numbers into your array, how would you check to make sure that you are getting only unique numbers?

start coding, post what you come up with, then well check back in again.
Mar 22 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.