Ch2_PascalInput Output

Ch2_PascalInput Output - Input and Output Input Read, and...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 1 Input and Output • Input – Read, and Readln • Output – Write, and Writeln • Unless specified Pascal uses fixed width output fields or numeric output • Blanks precede output, right justified 2 Formatting integers • The following statement: Writeln(123) will give as output the following: – 123 – The number is printed using 3 spaces • Writeln (123:5) will displays the number 123 using five spaces: – - -123 • Specifying the number of spaces used to print a number is called “Formatting” . 3 Formatting Integers(Cont.) Examples See Tables in Page_43 4 Formatting Reals • The following statement writeln(123.4) will print the following: – 1.234000000E+2 (Scientific Format) • writeln(1.234:5:2) will print the following: – -1.23 • Syntax for formatting reals: – write (real-number: x: y) – y specifies the number of decimal numbers – x specifies the width of number. 5 Formatting Reals (Cont.) Examples See Table in Page_45 6 Formatting Strings • Syntax: – write (‘String’: X) – X specifies the field width (How many spaces will be used to print the string) – Example: write(‘a’: 5) will print the following: - - - -a (Five spaces used to print a) • Example: Page_46
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 7 Formatting Strings Examples 8 Write Vs. Writeln • Write: – No carriage return at the end of printing
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/04/2009 for the course SSE CSC 1400 taught by Professor Mhamdi during the Spring '09 term at Al Akhawayn University.

Page1 / 5

Ch2_PascalInput Output - Input and Output Input Read, and...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online