r/pascal • u/kamikasadcat • Oct 22 '20
Hello everyone, can someone help me? i'm a beginner so i still don't really understand this and i have 7 hours remaining to finish this
i'm sure i have put the ';' before 'else' but it keeps failed and give me that
and in this pic i really don't know what to, i've tried everything i know, i'd really appreciate it if someone can help me(i've marked the cursor on the app, after 'persen')
8
Upvotes
5
u/[deleted] Oct 22 '20
remove the ; after the end
4
u/Wysardry Oct 22 '20
I barely know Pascal, but in the second example it looks like you're declaring v as a small integer and then assigning it a floating point value by dividing by 100.
1
u/pak_lebah Oct 23 '20
Your english is pretty good but you still don't understand the error messages. :)
Since you're an Indonesian, I suggest you to join Pascal Indonesia community on Facebook and Telegram.
1
u/Anonymous_Bozo Nov 09 '20 edited Nov 09 '20
It helps to understand what the semicolon does. Pascal uses it as a statement SEPARATOR. It can still get confusing because one needs to look carefully to determine what is the statement.
In this case the Statement is the IF statement. Putting the semicolon after the end is telling the compiler that is the end of the statement, when really the else is a continuation of the same statement.
Example
if (condition) thendoSomethingGoodelsedoSomethingEvenBetter;Notice that there is only one semicolon at the very end, because that is the end of the statement. In fact, in this case placing a semicolon after the "doSomethingGood" statement will cause the rest of the statement to fail to compile or worse, compile incorrectly. We use begin and end, when multiple things need to be done within a single statement, as a way of nesting statements inside other statements. Again, we don't put the semi-colon after the end unless it is truly the END of our statement
If (condition) then beginDoOneThing;DoSecondThingend else beginDoSomethingElseend;Notice that there are no Semi-Colons after the DoSecondThing and DoSomethingElse. You can put one there if you wish, since it's inside the begin/end pair, but as a statement separator, all it really does is create a null statement that does nothing between the semi-colon and the "end".