### Using Arrays

I am in my first C++ class and we are using the book C++ For business programers. We have just started capter 6 which covers arrays and I am lost The book wants me to write a program that prompts the user to enter the 5-digit zipcode of a customer Store the zip in array of intergers, and store the counts of customers in a corresponding array of intergers Assume a maximum of 100 zips. When a zip is entered the program should search the zip array. If it is not in the array it should add it to the end of the array and set the corresponding count array to one If the zip is already present in the zip array, it should increment the corresponding count array When the user completes entering zips, the program should display a table that lists all the zps with their counts and the percent that is of the total number of customers. The total number of customers should also be displayed.Please help!!!!!!!!

Code:
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{

const int Num_Zips = 10;
const int Num_Members = 20;

int Members[Num_Zips][Num_Members];
int Zipcode,
Member_Count;

cout << setprecision(1)
<< setiosflags(ios::fixed)
<< setiosflags(ios::showpoint);

cout << "nter your Zip Code." << endl;

for (Zipcode = 0; Zipcode < Num_Zips; ++ Zipcode)
{
cout << endl;
cout << "Enter the zip code for each member " << Zipcode + 1 << ": ";
cin >> Zipcode;
}

cout << endl;
cout << "The zip codes you entered were: ";

for (Zipcode = 0; Zipcode < Num_Zips; ++Zipcode)
cout << setw(5) << Zipcode;

return 0;
}
hello.i am trying to read you're code because i don't have so many c++ knowledge.i started with c,and just beginner in c++.and i don't now all the functions.
`setw();<< setiosflags(ios::fixed)`
things like that.but y have one question..why you increment first in the for loop
`++ Zipcode`,i guess you now that is different than `Zipcode++`
@Mihay07
 `++ Zipcode`,i guess you now that is different than `Zipcode++`

No, it makes no difference in this context (actually using preincrement (`++Zipcode`), is a better practice).
@OP
Next time put your code in [code][/code] tags.
Start from a simple program, then add more functionalities. First make a program which just ask the user for simple numbers, and fill up a one dimensional arrays with those numbers. Then make a program which before adding the element to the array searches through the array to see if it's already there. From here, you're almost done. If you have any specific question, feel free to come back.

You don't have any arrays actually working in your program... You need to get your arrays in order first, and than one a zip code is entered, make another loop that will run from the 0th element of the array, to the end, checking each number in the array against the number just entered, and if it matches, just have them re-enter a zip code.
Topic archived. No new replies allowed.