[cs13001] lab project 4
Mikhail Nesterenko
mikhail at cs.kent.edu
Fri Feb 7 19:26:38 EST 2014
> The lab does not state it, but is it ok, or
> frowned upon, to add a "do while loop" with an "ask before
> iteration" to allow the user to replay as often as they like?
For the first part of Lab 4 (scientific calculator), do-while seems to
be appropriate. For the second part (guessing game), depending on how
you structure your code, either while or do-while would work.
In general, try to avoid code where you write statements (e.g. initial
input) before the loop and then duplicate them inside the loop.
For example
cout << "input number: ";
int i;
cin >> i;
while (i > 0) {
cout << "input number";
cin >> i;
}
code duplicates prompt and input and is a good candidate for
re-writing as do-while.
Thanks,
--
Mikhail
More information about the cs13001
mailing list