I need some help!

I am writing a program for school and am unable to get ahold of anyone to help me out.
The errors I am encountering are:
- error C2446: '<' : no conversion from 'int' to 'int *'
- error C2040: '<' : 'int [5]' differs in levels of indirection from 'int'
The same two errors are repeated throughout my code on each operator.

I have been tring to fix this problem pretty much all day, and am at wits end with it. So if you can, please help me.
I'm not looking to have the answer handed to me, I just want someone to explain it to me. That way I can avoid such a problem in the future.

My code, if necessary, is as follows.

// Start Program
#include <iostream>
using namespace std;

// Function Prototypes
void ShowSelection();


int main()
{

// Define Variables
const int Num_Males = 5, Num_Females = 5; //Set Array
int height[Num_Males][Num_Females];
int weight[Num_Males][Num_Females];
int count; // Loop counter
char choice; // States that the user will use a character for a selection

// Say hello
// Display Selection
// Get users input
cout << "Welcome!\n";
ShowSelection();
cin >> choice;

// describe each choice with case statements using the fall down method
switch (choice)
{
case 'a':
case 'A': cout << "You Chose " << Num_Males << " Males.\n";
for (int count = 0; count < Num_Males; count++)

{
cout << "Enter The Height Of Male "
<< (count + 1) << ": ";
cin >> height[count];

cout << "Enter The Weight Of Male "
<< (count + 1) << ": ";
cin >> weight[count];
cout << endl;
}
break;

case 'b':
case 'B': cout << "You Chose " << Num_Females << " Females.\n";
for (int count = 0; count < Num_Males; count++)
{
cout << "Enter The Height Of Female "
<< (count + 1) << ": ";
cin >> height[count];

cout << "Enter The Weight Of Female "
<< (count + 1) << ": ";
cin >> weight[count];
cout << endl;
}
break;

case 'c':
case 'C': cout << "Have A Nice Day!\n";
system("pause");
return 0;
} // End Switch

if(choice == 'a' || choice == 'A' && height[count] < 76 && height[count] > 67) // Higher Male Heights(68-75)
{
if (weight[count] > 165) // Weights > 165 = high

cout << "Your Body Weight Is High.\n";

else if (weight[count] <= 165 && weight[count] > 155) // Weights 156-165 = Target

cout << "You Are At Target Body Weight.\n";

else if (weight[count] > 0) // Weights < 156 = Low
// set to zero to cover all weights below 156
cout << "Your Body Weight Is Low.\n";
}

if(choice == 'a' || choice == 'A' && height[count] < 68 && height[count] > 60) // Lower Male Heights(61-68)
{
if (weight[count] > 150) // Weights > 150 = high

cout << "Your Body Weight Is High.\n";

else if (weight[count] <= 150 && weight[count] > 133) // Weights 134-150 = Target

cout << "You Are At Target Body Weight.\n";

else if (weight[count] > 0) // Weights 123-133 = Low
// set to zero to cover all weights below 156
cout << "Your Body Weight Is Low.\n";
}

if (choice == 'b' || choice == 'B' && height[count] < 72 && height[count] >= 65) // Higher Female Heights(65-71)
{
if (weight[count] > 157) // Weights > 157 = High

cout << "Body Weight Is High.\n\n";

else if (weight[count] <= 156 && weight[count] >= 136) // Weights 136-156 = Target

cout << "Target Body Weight.\n\n";

else if (weight[count] > 0) // Weights 117-135 = Low

cout << "Body Weight Is Low.\n\n";
}

if (choice == 'b' || choice == 'B' && height[count] < 65 && height[count] >= 58) // Lower Female Heights(58-64)
{
if (weight[count] > 133) // Weights > 133 = High

cout << "Body Weight Is High.\n\n";

else if (weight[count] <= 133 && weight[count] >= 115) // Weights 115-133 = Target

cout << "Target Body Weight.\n\n";

else if (weight[count] > 0) // Weights 100-114 = Low

cout << "Body Weight Is Low.\n\n";

}


system("pause"); // pause system to see results
return 0; // End Program
}

void ShowSelection()
{
cout << "Choose From The Following.\n";
cout << "A: 5 Males.\n";
cout << "B: 5 Females.\n";
cout << "C: Quit.\n";
}

The main cause of your errors is that you define height and weight as multidimensional arrays at the beginning of your main function. However you then try and insert values into them treating them as singular arrays. Such as
cin >> height[count];
and
if (weight[count] > 157)

You will either need to change your statments to they access the arrays correctly such as this.
cin >> height[count][count] (or however you want them to be set up)

Or else change the beginning ones to singular dimensional arrays.

In this case I would think it would be easier to create a struct/class that includes both height and weight. Then create 2 singular arrays with that struct (for male and female). Then just enter in the info that way, but it depends on what you are currently learning.

Here is the reference page for multidimensional arrays if you want to do it that way. http://www.cplusplus.com/doc/tutorial/arrays/
Last edited on
Thanks a million!
That seemed to fix the errors, but still gave me a run time error. So, I'll probably have to do as you said and change the beginning of the array to singular. I appreciate your help!
Topic archived. No new replies allowed.