View Single Post
  #1 (permalink)  
Old September 27th, 2016, 08:50 AM
Tonell1618 Tonell1618 is offline
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2016
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.