Solved

Counting Items in an Array

Posted on 2000-04-03
3
241 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 100 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
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 …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

752 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