1 / 22

Pascal Programming

Pascal Programming. Written by Leung King Yung. Simple Program 1. begin end . Simple Program 2. program Test; uses wincrt; begin writeln( ‘Good Afternoon!’ ); end . Simple Program 2. Results:. Reserverd Words.

jolanta
Télécharger la présentation

Pascal Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Pascal Programming Written by Leung King Yung

  2. Simple Program 1 begin end.

  3. Simple Program 2 program Test; uses wincrt; begin writeln(‘Good Afternoon!’); end.

  4. Simple Program 2 Results:

  5. Reserverd Words begin end program var string if then else for to downto while do repeat until procedure function in These are the common reserved words of pascal program. You cannot use this as a variable name.

  6. Program Title program Test; {This is the program title(you can omit it)} begin {Main Body} end.

  7. Data type These are the common data type of pascal program.

  8. Declaring variable program Test; vari : integer; vars : string; varc : char; varb : boolean; varr : real; begin {Main Body} end.

  9. Declaring variable program Test; Uses wincrt; vari : integer; s : string; c : char; b : boolean; r : real; Begin I := 0; Writeln(i); end.

  10. Using Library program Test; uses wincrt; {Wincrt is a common library in turbo pascal for i/o manipulations wincrt.tpu} vari : integer; begin {Main Body} end.

  11. Using Variables program Test; uses wincrt; vari : integer; Begin Readln(i); writeln(i); end.

  12. Using Variables Results:

  13. Using Variables program Test; uses wincrt; vari : integer; j : integer; begin i := 7; j := 3; i := i + j; writeln(i); end.

  14. Using Variables Results:

  15. Comparing VB with Pascal VB: Dim i as integer Pascal: vari : integer; VB: i = 10 Pascal: i := 10; VB: ‘comment Pascal: {Comment}/(*Comment*)

  16. Comparing VB with Pascal VB: Dim j as integer j = 10 If j = 10 then print “J = 10” Else print “J <> 10” End If

  17. Comparing VB with Pascal Pascal: Useswincrt; varj : integer; begin j := 10; ifj = 10then writeln(‘J = 10’) else writeln(‘J <> 10’); End.

  18. IF…THEN…ELSE program Test; varj : integer; begin j := 10; ifj = 10then writeln(‘J = 10’) {*** No “;”} else writeln(‘J <> 10’); writeln(‘End of program’); end;

  19. IF…THEN…ELSE program Test; varj : integer; begin j := 10; ifj = 10then writeln(‘J = 10’) else writeln(‘J <> 10’); writeln(‘End of program’); end; The whole If-Phrase

  20. Complicated IF…THEN…ELSE ifi = 10then ifj = 10then writeln(‘i = 10 and j = 10’) else writeln(‘i = 10 and j <> 10’) else writeln(‘i <> 10 and j <> 10’); Correct Program

  21. Complicated IF…THEN…ELSE ifi = 10then ifj = 10then writeln(‘i = 10 and j = 10’) else writeln(‘i = 10 and j <> 10’); else writeln(‘i <> 10 and j <> 10’); Wrong semicolon (Syntax Error)

  22. Comment begin {This is a comment} (* This is also a comment*) end.

More Related