1 / 6

Input and Output (2)

Input and Output (2). Input Statement. Input Statement. Read user input from the keyboard Then assign the value read to a variable There are two input statements in Pascal read readln. readln statement. Syntax: readln ( <input list> )

tarak
Download Presentation

Input and Output (2)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Input and Output (2) Input Statement

  2. Input Statement • Read user input from the keyboard • Then assign the value read to a variable • There are two input statements in Pascal • read • readln

  3. readln statement • Syntax: • readln ( <input list> ) • <input list> could be a single variable or a list of variables separated by commas • All entries in the <input list> must be variable • Input data is read after the user press Enter key

  4. readln statement (cont.) • Example • var Num1, Num2 : integer; • readln ( Num1 ); • readln ( Num2 ); • writeln ( ‘The numbers are ‘, Num1, ‘, ‘, Num2); 5  8  The numbers are 5, 8

  5. Read more than one variable • To read more than one variable in the same row, put more than one variable in the <input list> in the readln statement and separate these variables with commas • Keyboard inputs are separated by blank space, tab or new line

  6. Read more than one variable • If the number of input values is more than the number of variables in <input list>, excess values are ignored • If the number of input values is less than the number of variables in <input list> when user press Enter, it will wait for more input from user.

More Related