Presentation is loading. Please wait.

Presentation is loading. Please wait.

Written by Al.So. Software solutions

Similar presentations


Presentation on theme: "Written by Al.So. Software solutions"— Presentation transcript:

1 Written by Al.So. Software solutions
Pascal Programming Written by Al.So. Software solutions

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 These are the common reserved words of pascal program. You cannot use this as a variable name. begin end program var string if then else for to downto while do repeat until procedure function in

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

7 Additional explanation
Data type These are the common data type of pascal program. Type Explanation Additional explanation Example integer Whole numbers 3, 104, 0, -9 string String variable (Text) 'Hello World', '456,4' char Character (One character) 'b', 'A', '7' boolean Boolean variable Can only be True or False True, False real Real numbers (Floating point numbers) 4.0, -0.08, 48.6, 2.0E4

8 Declaring variable program Test; var i : integer; var s : string;
var c : char; var b : boolean; var r : real; begin {Main Body} end.

9 Declaring variable program Test; Uses wincrt; var i : 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} var i : integer; begin {Main Body} end.

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

12 Using Variables Results:

13 Using Variables program Test; uses wincrt; var i : 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: var i : integer; VB: i = 10 Pascal: i := 10; VB: ‘comment Pascal: {Comment}/(*Comment*)

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

17 Comparing VB with Pascal
Uses wincrt; var j : integer; begin j := 10; if j = 10 then writeln(‘J = 10’) else writeln(‘J <> 10’); End.

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

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

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

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

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


Download ppt "Written by Al.So. Software solutions"

Similar presentations


Ads by Google