際際滷

際際滷Share a Scribd company logo
TURBO PASCAL
Pascal programming language was developed by
Niklaus Wirth Swiss computer scientist in early 1970.
This programming language is designed intentionally to
teach structured programming concepts, principles, and
paradigm future programmers. This can be done strictly
enforcing a set of rules(syntax) regarding the
declarations f variables, program structure, and flow of
control.
Elements of the Program

-smallest parts of the program that have separate
  and identifiable meaning.
Four classes of Elements
1. Reserved words
2. Identifiers
3. Constants
4. symbols
Program Structure
Headings
  - is the first statement in our program. It consists of a reserved
  word program then followed by the program name.
Declarations
  - The declarations part in our program consists usually with the
  list of variables.
Variables are memory location (address) which can assign a
  specific name.
  example: No, Sum, Area, Max or Min
Constants are assigned values that we specify to a particular name.
Example:         Pi = 3.1416
                 Interest=0.3;
                 Hours work= 8;
Labels are used to mark points in some part of the program.
Basic Data types f Pascal

  Data Type                   Meaning
Integer an integer data type is a whole number. This
  number could be positive or negative number.
           Example: 9 300 34
Real a real data type is a number with fractional part
  or a number with decimal point
  Example: 1.0 1777.456 3.1416
Character - is a single letter, a special symbol or
     digit that are enclosed within a single
 quotation marks.
     ex. a Z 7 * % A
Strings      - is a sequence of two or more characters
 that are enclosed within a single quotation marks.
     ex. Ms Tin
Input/ Output Statements
Writeln and write are the basic output statements of
 Pascal programming language.

write- is usually used with the gotoxy() standard
 function to center the message or o specify the
 location where the message should be displayed on
 the screen.
Readln,read and readkey are the basic input
 statements of Pascal programming.
Read command is used with the gotoxy() function.
Readkey command is used to read a character from
 the keyboard without echoing a response or display
 on the screen.
Usually our program involves three main
operations:

INPUT operation  in this part
     of our program we                         enter
 the needed                              data.
Process operation the data we entered is being
 computed, evaluated, stored, or processed.
Output operation  is the last part of
 programoutput on the screen.
Input / Output Statements

Writeln and write are the basic output statements of
 Turbo Pascal.
The Write command is usually used with the gotoxy()
 standard function to center the message or to specify
 the location where the message should be displayed
 on the screen
Readln, read and readkey are the basic input
 statements of Pascal.Usually read command is used
 with the gotoxy() function. The readkey command
 is used to read a character from the keyboard
 without echoing a response or display on the screen.
 Usually, the application of readkey is used to
 replace readln statement before the end statement.
Example


Algorithm:
INPUT      -Enter two numbers(N1,N2)
PROCESS- Compute the Sum
  (Sum:=N1+N2)
OUTPUT- Display the Sum(Sum)
Solution:

program Add;
uses crt;
var
        N1,N2:      integer;
          sum: integer;
begin
clrscr;
writeln( Enter two numbers: );
readln(N1,N2);
Sum:=N1+N2;
writeln(The sum:,Sum);
readln;
End.
Shortcut Key

F9    - run
Alt+f9  compile
F2    - file menu

More Related Content

Turbo pascal

  • 1. TURBO PASCAL Pascal programming language was developed by Niklaus Wirth Swiss computer scientist in early 1970. This programming language is designed intentionally to teach structured programming concepts, principles, and paradigm future programmers. This can be done strictly enforcing a set of rules(syntax) regarding the declarations f variables, program structure, and flow of control.
  • 2. Elements of the Program -smallest parts of the program that have separate and identifiable meaning. Four classes of Elements 1. Reserved words 2. Identifiers 3. Constants 4. symbols
  • 3. Program Structure Headings - is the first statement in our program. It consists of a reserved word program then followed by the program name. Declarations - The declarations part in our program consists usually with the list of variables. Variables are memory location (address) which can assign a specific name. example: No, Sum, Area, Max or Min Constants are assigned values that we specify to a particular name. Example: Pi = 3.1416 Interest=0.3; Hours work= 8; Labels are used to mark points in some part of the program.
  • 4. Basic Data types f Pascal Data Type Meaning Integer an integer data type is a whole number. This number could be positive or negative number. Example: 9 300 34 Real a real data type is a number with fractional part or a number with decimal point Example: 1.0 1777.456 3.1416
  • 5. Character - is a single letter, a special symbol or digit that are enclosed within a single quotation marks. ex. a Z 7 * % A Strings - is a sequence of two or more characters that are enclosed within a single quotation marks. ex. Ms Tin
  • 6. Input/ Output Statements Writeln and write are the basic output statements of Pascal programming language. write- is usually used with the gotoxy() standard function to center the message or o specify the location where the message should be displayed on the screen.
  • 7. Readln,read and readkey are the basic input statements of Pascal programming. Read command is used with the gotoxy() function. Readkey command is used to read a character from the keyboard without echoing a response or display on the screen.
  • 8. Usually our program involves three main operations: INPUT operation in this part of our program we enter the needed data. Process operation the data we entered is being computed, evaluated, stored, or processed. Output operation is the last part of programoutput on the screen.
  • 9. Input / Output Statements Writeln and write are the basic output statements of Turbo Pascal. The Write command is usually used with the gotoxy() standard function to center the message or to specify the location where the message should be displayed on the screen
  • 10. Readln, read and readkey are the basic input statements of Pascal.Usually read command is used with the gotoxy() function. The readkey command is used to read a character from the keyboard without echoing a response or display on the screen. Usually, the application of readkey is used to replace readln statement before the end statement.
  • 11. Example Algorithm: INPUT -Enter two numbers(N1,N2) PROCESS- Compute the Sum (Sum:=N1+N2) OUTPUT- Display the Sum(Sum)
  • 12. Solution: program Add; uses crt; var N1,N2: integer; sum: integer; begin clrscr; writeln( Enter two numbers: ); readln(N1,N2); Sum:=N1+N2; writeln(The sum:,Sum); readln; End.
  • 13. Shortcut Key F9 - run Alt+f9 compile F2 - file menu