Need help with my code

I need help with my code but I don't want to make it public, My loop is not ending and I need to figure out a way to change or add something to my program that allows to have a certain amount combined in two containers.

So if I have a container that holds 5 and one that holds 3 and I need 7 units, I need to have outcome of 4 units in one and 3 in the other or 5 units in one and 2 in the other.


I'll send my code in a PM if you guys do not mind
Im new at coding but have you tried adding something like this to the end of your loop:

int con1, con2, sum;
con1 = 5;
con2 = 2;
sum = con1 + con2;

if(sum == 7)
{
std::cout << "they equal and loop is over" << endl; // have return 0; here instead

}

of course the variables would be slightly different and their values would change.
Last edited on
@kenandcrys - You're using the wrong operator in your if statement.
= is the assignment operator. == is the equality operator.

You're assigning 7 to sum, then testing if the result is non-zero.
@Abstraction - Yep, I sure am, thank you for letting me know. I didnt see it the first time.
Last edited on
Topic archived. No new replies allowed.