Knight7770
Hippopotomonstrosesquiped aliophobia
- Reaction score
- 187
Once again, I am at a loss for how to fix this comparison not working. The compiler doesn't give me any errors, but it is obvious that the comparison does not work. Here is the code:
The comparison:
The setting of total_stocks[]:
The else to match the if:
The setting of objective:
The problem is that the if statement always seems to be true. I even output total_stocks[] to make sure that it's greater than objective, and even when it is, the if statement always seems to be true.
If you need more code, just ask.
Thanks :thup:
The comparison:
Code:
if(total_stocks[0]<objective||total_stocks[1]<objective||total_stocks[2]<objective||total_stocks[3]<objective||total_stocks[4]<objective||total_stocks[5]<objective||total_stocks[6]<objective||total_stocks[7]<objective||total_stocks[8]<objective||total_stocks[9]<objective)
The setting of total_stocks[]:
Code:
for(int a=0;a<iPlayers;a++)
{
total_stocks[a]=cookies[a]+muffins[a]+pies[a]+cakes[a];
std::cout<<total_stocks[a]<<"\n";
}
The else to match the if:
Code:
else{
std::cout<<"You win! Yay!\n";
return 0;
}
The setting of objective:
Code:
std::cout<<"How many stocks would you like to reach in order to be victorious? (Enter a negative number to play continuously)\n";
std::cin>>objective;
The problem is that the if statement always seems to be true. I even output total_stocks[] to make sure that it's greater than objective, and even when it is, the if statement always seems to be true.
If you need more code, just ask.
Thanks :thup: