Firstly, you are missing type definitions. The first loop requires
type to be defined and looking at what it's being compared with, I'd say that it's a
char. In the second loop, I'd say that
exposure must be an
int. If I redo the code, it becomes.
Language: C++
cout<<" Does the client want normal size or jumbo photos? " <<endl;
char type;
do
{
cout<<" Please enter ';n'; for normal or ';j'; for jumbo) :";
cin >> type;
}while (type != ';n'; && type != ';j';);
cout<<" Please key in the film exposure:" << endl;
int exposure;
do
{
cout<<" Valid exposures are 12, 24 and 36 :";
cin>>exposure;
}while (exposure !=12 && exposure !=24 && exposure != 36);
Now that that's out the way, the first while loop's condition says, "while type is not the character 'n' and type is not the character 'j' keep looping". Basically, keep looping if neither of those characters are entered by the user.
The second conditional says, "while exposure is not 12 and exposure is not 24 and exposure is not 36, keep looping". Keep looping till one of those three options is entered by the user.
I know that sometimes logical statements might not seem intuitive because we usually don't talk like that amongst ourselves. You would probably say something like, "keep looping
till type is either 'n' or 'j'". If you flip this round, you would say "keep looping
while type is neither 'n' nor 'j'".
In logic, this last statement would be NOT ('n' OR 'j'
. Using de Morgan's equivalence[1], this transforms to (NOT 'n' AND NOT 'j'
Similarly, you can get the second one by saying, "keep looping till exposure is either 12, 24 or 36". Flipping the logic, but keeping it equivalent, gives you, "keep looping while exposure is neither 12, 24, nor 36".
[1] de Morgan proved that NOT (X OR Y) == NOT X AND NOT Y. The converse is also true.
Also NOT X OR NOT Y == NOT (X AND Y). This form of the proof is not needed in your example but is good to remember.