I found that semi-colon are some time come to the end of the line. i.e.: end, else,... But just some time. Could you tell me when I need to put semi-colon to the line? And when I need not?

if (condition true)then Do something;
 {if you want to an 'else' part too then,do not put semi-colon}
if (condition true)then Do something  {do not here}
Else Do anything;{Here}
Because the semicolon at the end of 'if statement' is the sort version of 'If'

{or the Begin..end;}
{ if it is not the block of main begin..end then you have to put semicolon

Procedure Hello;
  End;   {see?}

Begin  {main}
   {call our procedure}
End.   {see?}
His answer is very clear to me.

In Pascal, a semicolon separates statements (and terminates directives).

So the following is correct:

program Hello;  { Semicolon terminates directive }
  writeln( 'Hello world!' )  { No semicolon necessary }

As is:

program Hello;
  write( 'Hello ' )
  ;  { semicolon separates statements }
  writeln( 'world!' )

Since an if then..else block is one statement, there should not be any semicolons between the 'then' and 'else' parts:

if prime( users_number )
  then writeln( users_number, ' is prime.' )  { statement not ended }
  else writeln( users_number, ' is composite.' );  { now it is at the end }

Even nested ifs must obey:

if foo
  then if bar
         then baz
  else quux;

Notice how if foo is true but bar is not, there is an empty statement there (or not there - depending on how you look at it ;) ).

This is the same in code like:

  writeln( 'Woah, there are actually TWO statements here.' );

Hope this helps.

This question has already been answered. Start a new discussion instead.