Solved

Counting Items in an Array

Posted on 2000-04-03
3
234 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 100 total points
Comment Utility
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
Comment Utility
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
Comment Utility
>> 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now