I need this program to be able to display 4th quarter inventory in this format:

October 200
November 250
December 350

I need it to display in an array. This what i have so far:

#include <iostream>
#include <fstream>
#include <iomanip>

using namespace std;

int main()
{
    const int N_MONTHS = 12;
    int stock;
    int values[N_MONTHS];
    int count;
    double total = 0;
    double avg;
    int largest;
    int smallest;
    string p_months[N_MONTHS] = { "January", "February", "March", "April",
                                  "May", "June", "July", "August", "September",
                                  "October", "November", "December" };
                                  
    for ( int month = 1; month <= N_MONTHS; month++ ){
        cout << "Enter the number of items in stock for the month of " << p_months[month-1] << ": ";
        cin >> stock;
        
        if ( stock < 0 ){
             cout << "The number you have entered is invalid." << endl;
             cout << "Please reenter: ";
             cin >> stock;
        }
    values[month-1]=stock;
    total += stock;            
        total += stock;
    }
    
    cout << "The amount of items in stock is: " << total << endl;
    avg = total / (double)N_MONTHS;
        
     for ( int month = 1; month <= N_MONTHS; month++ ){
         largest = values[0];
         for ( count = 1; count < N_MONTHS; count++ ){
             if ( values[count] > largest ){
                  largest = values[count];
             }
         }
        
         smallest = values[0];
         for ( count = 1; count < N_MONTHS; count++ ){
             if ( values[count] < smallest ){
                  smallest = values[count];
             }
         }
     }
    
    cout << "Items in stock for the fourth quarter are as follows " << endl;
    cout << N_MONTHS+9 << endl;
    
    
    
    system("pause");
    return(0);
}

I have gotten it as far as I can think of. My brain is fried and I am frustrated.

> total += stock;
> total += stock;
Why are you doing this twice?

If you want to do stuff on the 4th quarter, then you need to loop over months 9 to 12 (not 12 + 9)

Where am I doing 9 to 12? I dont see it. Forgive me, but I have been looking at code for weeks.

>>for ( int month = 1; month <= N_MONTHS; month++
Array elements start at 0, not 1 and that loop should too for ( int month = 0; month < N_MONTHS; month++ ) >> cout << N_MONTHS+9 << endl;
What is that supposed to be? Why display the number 21 (which is N_MONTHS+9)?

>>Where am I doing 9 to 12?
You aren't and that's one of the problems. You need to add it to the end of the program that you posted.

>>I dont get it!

>>I need this program to be able to display 4th quarter inventory

The 4th quarter is the three months October, November and December. You have an array values that contains all 12 months. So the last three months are values[9], values[10] and values[11]. So display each of those values as indicated in your original post. And do that just before the line system("pause");

This article has been dead for over six months. Start a new discussion instead.