Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Counting Items in an Array

Posted on 2000-04-03
3
Medium Priority
?
244 Views
Last Modified: 2010-04-02
I'm stomped.  I have to write a C++ program that creates an array of part numbers and prices.  The program must be equipped with an error function that seperates valid part numbers (within preset parameters) from invalid part numbers.  I think I have it relatively bug free except I need to know the series of commands that counts the actual items within an array.  Specifically, I need my program to count the amount of times a part number that was entered is valid and the amount of part numbers that are invalid.  Your help will be greatly appreciated.  Also, if you know where I can find various examples of C++ array code, that would be great.
0
Comment
Question by:nploving
  • 2
3 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 400 total points
ID: 2681392
obviously we don't know how to seperate good numbers from bad, you'll have to do that, but the code woudl be something line

const int MaxItemCount = 100;
int PartArray[MaxItemCount];
int GoodCount = 0;

for (int i =0; i < MaxItemCount; ++i)
{
   if  (PartNumberIsGood[i])
      ++GoodCount;
}

// GoodCount is now the count of the number of good items.

\Let me know if you have any questions.
0
 

Author Comment

by:nploving
ID: 2681629
Very good, but how do I count the part numbers that don't show up in this array.  Do I create a seperate array for parts not found.  I'm pretty lost here.  Do you know where I can find a bunch of examples of C++ array programs so that I can get a feel for what functions to use in various situations.  It would help me alot if you could take a look at what I've done.  I hope its not asking too much, but I'm in a pinch.  Thanks.
0
 
LVL 22

Expert Comment

by:nietod
ID: 2682135
>> how do I count the part numbers that don't
>> show up in this array.  Do I create a seperate
>> array for parts not found.
I can't really say.  It depends on what the program needs to do--overall.

>> Do you know where I can find a bunch of
>> examples of C++ array programs
Almost no programs don't use arrays.  Arrays can be used in so so many this isn't likely to help you.  Better to develope what you need for this case.  I can probably help, but I don't know what you need to do.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
Suggested Courses
Course of the Month13 days, 7 hours left to enroll

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question