I would like my program to execute some code using random variables. Whether this happens is dependant of three conditions:
1) a variable (first) should be bigger than an other (second)
2) a variable (third) should be equal to an other (fourth)
3) it should check these thing maximum 5 times (iteration)
If the first AND second condition are met, the do-while loop should stop and the following code should be executed. If after 5 times the program still hasn't picked the correct values, the do-while loop should also stop.
I'm having trouble using the || and &&.
Now i have something like this:
iteration = 0;
do
{
some code picking the values for the integers: first, second, third and fourth;
iteration++;
} while (first > second || third != fourth && iteration < 5);
execute the code with the chosen values;
I use the || because the loop should repeat if the first condition is true and the second is false (or vice versa).
I use the && because if the first or second condition is still false, but iteration = 5, I want the loop to stop.
With this placement of || and &&, the loop just keeps on running. ( I have made the code so that the first and second condition can't be met.)
could anyone explain what I'm doing (thinking :)) wrong?
thx