The program calls for:
Here is what the program calls for:

Write a program that lets a maker of chips and salsa keep track of their sales for 5 different types of salsa they produce: mild, medium, sweet, hot, and zesty. It should use two parallel 5-element arrays: an array of strings that holds the 5 salsa names and an array of integers that holds the number of jars sold during the past month for each salsa type. The salsa names should be stored using an initialization list at the time the name array is created. The program should prompt the user to enter the number of jars sold for each type. Once the sales data has been entered, the program should produce a report that displays sales for each salsa type, total sales, and the names of the highest selling and lowest selling products. Input Validation: Do not accept negative values for number of jars sold.

I get "error C2109: subscript requires array or pointer type" when I try to run the following code. Is it possible to run the array as a function to name of the jars and how much each sold?

#include <iostream>
#include <string>
using namespace std;

void showSold(int sales[], int salsa);

int main()
{
	const int SALSA = 5;
	string name[SALSA] = {"mild", "medium", "sweet", "hot", "zesty"}; //Salsa Types
	int sales[SALSA];
	int sold(),
		total(),
		highest(),
		lowest();

	cout << "Please enter the number of jars sold for each salsa\n";
	for(int count = 0; count < SALSA; count++)
	{
		cout << name[count] << ": ";
		cin >> sales[count];

		while(sales[count] < 0)
		{
			cout << "You must enter a number 0 or greater. Please try again\n";
			cin >> sales[count];
		}
	}

	
	showSold(sales, SALSA);

	return 0;
}

void showSold(int sales, int salsa)
{
	for(int count = 0; count < salsa; count++)
	{
		cout << "The amount each salsa sold are:\n";
		cout << sales[count] << " ";
		cout << endl;
	}
}

Sales is passed to the function as an integer, but in the line cout << sales[count]; you are treating it like an array.

Add a [] to sales on line 36-this will ensure the function will treat sales as an array.

Try this:

#include <iostream>
#include <string>
using namespace std;

void showSold(int sales[], int salsa);

int main()
{
	const int SALSA = 5;
	string name[SALSA] = {"mild", "medium", "sweet", "hot", "zesty"}; //Salsa Types
	int sales[SALSA];
	int sold(),
		total(),
		highest(),
		lowest();

	cout << "Please enter the number of jars sold for each salsa\n";
	for(int count = 0; count < SALSA; count++)
	{
		cout << name[count] << ": ";
		cin >> sales[count];

		while(sales[count] < 0)
		{
			cout << "You must enter a number 0 or greater. Please try again\n";
			cin >> sales[count];
		}
	}

	
	showSold(sales, SALSA);

	return 0;
}

void showSold(int sales[], int salsa)
{
	for(int count = 0; count < salsa; count++)
	{
		cout << "The amount each salsa sold are:\n";
		cout << sales[count] << " ";
		cout << endl;
	}
}
This question has already been answered. Start a new discussion instead.