Try it out: Using a Struct: Ch05Ex03\Program.cs (Pg 91)
code
.
.
.
do
{
Console.WriteLine("Select a direction:");
myDirection = Convert.ToInt32(Console.ReadLine());
}
while ((myDirection < 1) || (myDirection > 4));
/code
In code above, since we are using the OR '||' instead of the '|', shouldn't the code executes even if the user input let say '5' for e.g. Because, when using the '||', normally if the first expression is correct, the code executes, isn't it, so why here it does not act this way. I.e. if I insert '5', it would give me the 'Select a direction' again, but this should have occurred if you had use the '&&' AND operator and not the OR operator.
|