Lesson 1 - The First Few steps in Pascal Programming

In a program, you must always obey the rules of the language, in our case, the Pascal language. A natural language has its own grammar rules, spelling and sentence construction. The Pascal programming language is a high level language that has its own syntax rules and grammar rules. As you go along with the lessons, you must note what you can do and what you cannot do in writing a Pascal program. A very simple program is shown below: 
Program Lesson1_Program1;   
Begin    
 Write('Hello World. Prepare to learn PASCAL!!');
 Readln;   
End.
The program is written only to display the message : 'Hello World. Prepare to learn PASCAL!!' - an introductory message that is displayed to you whenever you are going to learn a new programming language. This is simply shown on the screen. So, to display any message on the screen, you should use 'write' (or 'writeln'). The 'readln' statement, here is used as to 'stop' the program and wait until the user presses enter. If the 'readln' statement is missing in this program, then the message is displayed on the screen without giving any chance for the user to read it and obviously halts! Try running this program with and without the 'readln' statement and notice the difference. I suggest you see it!! Now, look at this:
Program Lesson1_Program2;begin 
Write('Hello World. Prepare to learn PASCAL!!');Readln;End.
This program also runs perfectly as the previous one. The only difference is: neatness andfriendliness. 
This first program is, what is commonly referred to in programming, as 'indented'. Indentation is a must in writing programs as it aids in the way the code is written ie. neater. Indentation also helps with debugging and code presentation. You will note how I indent programs.
SHARE

Milan Tomic

Hai my name Edi Kustriyadi and l newbie :)

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment

luvne.com ayeey.com cicicookies.com mbepp.com tipscantiknya.com kumpulanrumusnya.comnya.com