Thread: Arrays

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    6

    Unhappy 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;
    }
    This all I have so far and it isn.t even close.
    Last edited by Thoggle; 09-06-2010 at 05:22 AM. Reason: Added my code so far

  2. #2
    Novice
    Join Date
    Jul 2009
    Posts
    568
    Here you go.
    Code:
    #include <iostream>
    
    using namespace std;
    
    int main(void) {
    
    
    }

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    So you read in the zip code. Then you have to store it. So why aren't you? Is there something specific you're confused about?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to create and manipulate Terabyte size Arrays with Win32API
    By KrishnaPG in forum Windows Programming
    Replies: 1
    Last Post: 11-05-2009, 04:08 AM
  2. pointers & arrays and realloc!
    By zesty in forum C Programming
    Replies: 14
    Last Post: 01-19-2008, 04:24 PM
  3. Replies: 16
    Last Post: 01-01-2008, 04:07 PM
  4. Need Help With 3 Parallel Arrays Selction Sort
    By slickwilly440 in forum C++ Programming
    Replies: 4
    Last Post: 11-19-2005, 10:47 PM
  5. Crazy memory problem with arrays
    By fusikon in forum C++ Programming
    Replies: 9
    Last Post: 01-15-2003, 09:24 PM