You have twice
else (mychoice == XXX)
, are you sure your compiler can understand that construct?
else (mychoice == rectangle){
If I was a C++ compiler I would expect
else; (mychoice == rectangle)
. Do you understand why?
cheers,
AR
OP: no I do not can you explain this
1. Read the article
Control Structures
[
^] from top to
Iteration structures (loops).
2. Read it again :) looking for the sentence :
if (condition) statement1 else statement2.
3. In your code find:
if (mychoice == square){
cout << "Enter the width: ";
cin >> width;
cout << width * 2;
}
else (mychoice == rectangle)
4. From this code identify the parts matching
condition,
statement1, and
statement2 in
if (condition) statement1 else statement2.
5. Is
(mychoice == rectangle)
a
statement?
6. The compiler finds a missing
statement after
else
and suggests
;
the simplest and shortest possible
statement.
What should you insert in
else (mychoice == rectangle)
to make your compiler happy?