Hi all,
I am tutoring introductory computer science in the Solomon Islands and
we are using C++ as the language of choice (nice). Please note that I
am no way a C++ programmer, but have but I have programmed in most
mainstream languages over the paste 20 years. We are learning HOW to
code, not just C++. The dudes in the class have their final assignment
in a couple of days and we have a simple problem to overcome. The
problem is this:
The program reads in an array of integers which instructs a robot which
direction to go in, in a 20 x 20 grid. The first two integers (read in
from a file) are the starting position of the robot, and have to be
validated in a function as a valid position within the 20 x 20 grid.
The starting postions are global variables in the file. The boolean
'valid' is declared as false also as a global. The code to validate is
as follows:
void check_valid( )
{
if ((start_x >= 0 || start_x <= 20) && (start_y >= 0 || start_y <=
20)) // you know what I mean
{
valid = true;
}
}
The problem is that if the initial start_x and start_y positions ARE
valid, the 'if' logic never work. Any replies come with a big Thanks In
Advance for these guys trying to get through their course in a time of
great uncertainty in the Solomons (just do a Google search and find out
about the troubles we've been through in the last few weeks).
Nick