Turbo Pascal is a programming language developed in the 1970s to teach structured programming concepts. It enforces rules around program structure, flow of control, and variable declarations. A basic Pascal program has a heading, declarations section, and input, processing, and output sections. It uses data types like integers, reals, characters, and strings. Common input statements are Read, Readln, and Readkey while output statements include Write and Writeln.
1 of 13
Downloaded 67 times
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.