There are problems at line 41.
|
while(choice == 'Y' || choice == 'y');
|
That's a logic error, the compiler will be happy enough, since the code is valid.
What you have there is an empty loop. The semicolon at the end of the line counts as a valid "empty statement".
We could rewrite line 41 like this:
1 2 3 4
|
while(choice == 'Y' || choice == 'y')
{
// empty loop body
}
|
One reason this is so easy to do is that visually a
do-while
loop and a
while
loop can be hard to distinguish. Code formatting can help the human reader (the compiler doesn't care).
Personally I adopt the convention that I place the opening and closing braces of a plain while loop on a line by themselves, like this:
1 2 3 4
|
while (condition)
{
}
|
On the other hand, I'd write a do-while loop like this:
1 2 3
|
do {
} while (condition);
|
How to format the code is a whole subject in its own right, and I only mention it as a way to add legibility - the human reading the code needs all the help they can get :)