1. Preliminary In general, a program designed to display the output. In a program that works according to user needs are varied, it would be better if also has the ability to accept input. With the ability to receive this input, the program can handle more than one state at once, so as to provide appropriate feedback given output. The ability to receive input also shows that a program can manipulate the input, provided that the input is still within the limits that have been specified according to the program through data types, type variables, and others. While still based on the text, in the Pascal programming language to be giving orders to the input and output vary, depending on needs. Input can be given in a series of characters / text or numbers, may be just one character or number, a pressure on one of the keyboard, or pressure on the Enter key. Display output can also be shown either in a line or shaped in some lines to facilitate reading. In its development, the program can be made in order to receive various inputs, but for initial training will be limited to first on the patterns of input and output display that is simple.
2. The word used reserve Program: The specification name of the program and its parameters, is decorative and not affect the overall program itself Uses: define the name of the unit to be referenced by the program Var: linking an identifier and its type with a location in memory where the values of these types can be stored Begin: starting a program block End: end a program block
3. The procedure used Write: writing a variable into a component file in a text file used to write one or more values to a file Writeln: executing the write procedure, then pulled out a marker of end-of-line (EOL) to the program files Read: read a file into a variable component, in a text file used to read one or more values into one or more variables Readln: executes a read procedure, and then move to the next line in program files
simple program.
a. Contoh pertama
Program m3bc1;
Uses wincrt;
Var
Index : byte;
Count : real;
What : boolean;
Letter : char;
Name : string[10];
begin
Writeln('Integer');
Index := 17;
Writeln(Index,Index);
Writeln(Index:15,Index:15);
Writeln;
Writeln('Real');
Count := 27.5678;
Writeln(Count,Count);
Writeln(Count:15,Count:15);
Writeln(Count:15:2,Count:15:2);
Writeln(Count:15:3,Count:15:3);
Writeln(Count:15:4,Count:15:4);
Writeln;
Writeln('Boolean');
What := FALSE;
Writeln(What,What);
Writeln(What:15,What:15);
Writeln('Char');
Letter := 'Z';
Writeln(Letter,Letter);
Writeln(Letter:15,Letter:15);
Writeln('String');
Name := 'John Doe';
Writeln(Name,Name);
Writeln(Name:15,Name:15);
Writeln;
Writeln('Text output','Text output');
Writeln('Text output':15,'Text output':15);
End.
Tidak ada komentar:
Posting Komentar