0% found this document useful (0 votes)
56 views12 pages

Introduction To Pascal Programming Language: Input / Output

This document discusses input and output in Pascal programming language. It explains that input is obtained using read() and readln() functions, which take user input and store it in specified variables. Output is displayed using write() and writeln() functions, with write() displaying on the same line and writeln() jumping to the next line. It provides examples of taking input and displaying output in Pascal, and also describes formatting of output values using field width and precision specifications.

Uploaded by

Ammar Danial
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views12 pages

Introduction To Pascal Programming Language: Input / Output

This document discusses input and output in Pascal programming language. It explains that input is obtained using read() and readln() functions, which take user input and store it in specified variables. Output is displayed using write() and writeln() functions, with write() displaying on the same line and writeln() jumping to the next line. It provides examples of taking input and displaying output in Pascal, and also describes formatting of output values using field width and precision specifications.

Uploaded by

Ammar Danial
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 12

Chapter 4

Introduction to Pascal
Programming Language
Input / output

Learning Outcomes
Upon completion of this lecture learners will
be able to:
Apply input and output command in Pascal
Write a complete sequential Pascal program that
involves input and output format.

Page 2 of 12

Input
In pseudocode, we get input from user by
having an instruction like
2.0 get num
In flowchart, we get input from user by
having an instruction like
Get num

Page 3 of 12

..Input
In Pascal, we use read() or readln() to get
input from user
Syntax

read (<variable list>);

Example

read (num);
read (num1, num2);

Syntax

readln (<variable list>);

Example

readln (num);
readln (num1, num2);
Page 4 of 12

..Input
read() and readln() take input from
keyboard and store the input in the specified
variable
Example
100
100
var num1,
num1
num2 : integer;
200

readln (num1, num2);

200
num2
Page 5 of 12

..Input
read() vs. readln()
read() treats inputs a stream of data until
end of line character found (press enter).
readln() will skip into the next line after a
number of inputs entered.
Example?

Page 6 of 12

Output
In pseudocode, we display output to user by
having an instruction like
2.0 display num
In flowchart, we display output to user by
having an instruction like
display num

Page 7 of 12

..Output
In Pascal, we use write() or writeln() to
display output to user
write() displays the output and the next output
continues in the same line.
Syntax

write(<variable list>);
write(constant string);
Write(constant string,variable);

Example

write(num);
write(Please enter a number --> );
write(Number one is , num1);
Write(x is, x, & y is , y);
Page 8 of 12

..Output
writeln() displays the output and jump to the
next line.
The next output continues in the next line.
Syntax

writeln(<variable list>);
writeln(constant string);
Writeln(constant string,variable);

Example

writeln(num);
writeln(Enter a number --> );
writeln(Number one is , num1);
Writeln(x is, x, & y is , y);
Page 9 of 12

Example

Page 10 of 12

Formatting Output
num = 45.9053
Writeln(num);
#4.590530000000000E+001
Writeln(num:5);
#4.6E+001
Writeln(num:5:2); 45.91
Writeln(num:7:3); #45.905
Writeln(num:6:5); 45.90530
Writeln(num:6:2, num:7:3);
#45.91#45.905
Page 11 of 12

Formatting Output

Page 12 of 12

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy