| Georgerm (3) | |||
|
Hello im new to the forums and figured I would sign up to see if anyone could help me with this problem I am having. I just started programming and am doing self exercises so I remember what I read and how it looks actually being done in a program, but doing this, i have come up with a syntax error. I am trying to use bolean statements with if/else if and else statements. The problem I am getting is that during my else statement which is else(age>21) { cout "" You are not allowed in"; } I keep getting an error that is tellingme that it is expecting a ; before the { I don't know if this is allowed but for further help to you guys ill write my code out and tell you on what line the error is
On the last else statment I keep getting the error:expected ';' before '{' token thing. I can fix it easily by putting the ; in, but I don't understand why it needs it. Also I woudl try putting a not statement in, but I still am a bit confused on how they work. Thanks in advance | |||
|
Last edited on
|
|||
| TheIdeasMan (1753) | |
|
You cannot have a condition with the else. Make it an else if. else is designed to catch any other condition. Please always use code tags - select your code then press the <> button on the right. There are other problems, but will help once there are code tags. Any compilation errors - post the full compiler output. | |
|
|
|
| Georgerm (3) | |
|
Ok sorry for the latency, I have put up the code with the instructions you have given me, I am using codeblocks for my compiler and the only specific error it has is.. Line 26 error:expected ';' before '{' token Im using Codeblocks, if there is anything i can do for you to help me, with other errors this program may have let me know. Also thanks for the quick responce | |
|
|
|
| guatemala007 (31) | |||||||
|
I fixed the bit of code you put up. Your main error was that you put a condition after an else statement, so either use an else statement without a condition or just use an else if statement and put your conditions after it ex. of else statement:
ex. of else if statement:
See corrected code for more instructions, and other mistakes.
| |||||||
|
|
|||||||
| Georgerm (3) | |
| Just got my internet back and would just like to say I got the problems running with the help of both of you, will be using this site for more help in the future, great great people thanks :)! | |
|
|
|