|
|
|
|
choice
is a character, and the program compares it with an integer. It should be '2'
rather than just 2
.num
which the user entered at the start? Lines 42, 46 and 50 are testing the wrong variable.
|
|
else
is under a red line and the program works perfectly, but shuts down after it because it doesn't seem to understand it and doesn't continue. Isn't it supposed to be like this?
|
|
}
Is having a red line under it.cout
statements.
|
|
{
and }
should be in matched pairs.
Anyway, currently, the program does not seem to crash when I tested it. However it does end normally without much in the way of useful output. |
|
|
|
|
|
|
|
|
<
or greater than >
sign here.
|
|
[Error] expected ';' before '{' token |
else (num > 100)
else if(num > 100)
chervil wrote: |
---|
Line 47 looks wrong. else(a > 100) The compiler may swallow it without a murmur, but it is definitely incorrect. The else should stand alone (it cannot have an attached condition). If another condition is necessary, then use another if. (Sometimes the else and if may be placed on the same line, so it looks like this: else if (a > 100) but remember the condition belongs to the if. Also, remember if you do add an if then it will also usually need its own corresponding else later. |
|
|
|
|
|
|
else (num > 100)
else
is used to control what happens when the previous if statement is not satisfied.
|
|
|
|
|
|
|
|
|
|
system("pause");
If i didn't put it, it shuts down?This is the final code, It works perfectly and gives me the right outcome.[/code][code] |
else (num > 100)
(num > 100)
cannot be preceded by else
all by itself. There must be an if
in there.
|
|
cout << “ Not valid \n “
[Warning] suggest explicit braces to avoid ambiguous 'else' [-Wparentheses] |
else
at line 31 match the if
at line 29, or does it match the if
at line 24?{
and }
where appropriate. These are as much to aid the human reader as to control the program logic.
|
|
|
|
chervil wrote: |
---|
Then you need to test it. what happens if the user enters 10 and then 2? what happens if the user enters 100 and then 2? |