Q1: Is one of these "better" form than the other?
do
{ ...
} while ( answer == 'y' ) || ( answer == 'Y');
OR
} while ( answer == ( 'y' || 'Y' ) );


Q1: Is one of these "better" form than the other?
do
{ ...
} while ( answer == 'y' ) || ( answer == 'Y');
OR
} while ( answer == ( 'y' || 'Y' ) );

A1: do
{ ..
} while ( ( answer == 'y' ) || ( answer == 'Y') ) ;
is better because ( 'y' || 'Y' ) is always TRUE
Think over the looping conditions. PA#3 stops only if N or n.
Therefore the program loops again if NOT n nor N ( != 'n' )


HOME || Course Description || Course Outline || Lab Hours || FAQ