22.30

Statement, statement on Pascal Programming

Chapter 2-Statements Statements in Pascal Programming
Well, now you've entered into chapter programming statement .... Good luck ... Reserved Word Reserved Word is the standard word used in the program and have terintergrated in pascals and also has a certain form and functionality that have been defined by Pascal. Reserved Word should not be redefined by the user, so can not be used as an identifier (Identifier). In the Pascal programming language, some reserved anatra Word in Pascal are:
Downto AND IN OF STRING ASM inherited OR ELSE THEN Packed inline ARRAYS TO END EXPORTS BEGIN PROCEDURE INTERFACE TYPE CASE FILE UNIT LABEL PROGRAM CONST FOR LIBRARY RECORD UNTIL Repeat constructor MOD FUNCTION USES GOTO Destructor SET NIL VAR DIV IF NOT WHILE SHL DO IMPLEMENTATION WITH OBJECT shr . Reserved Word Apart from the above, Turbo Pascal still has the following additional Reserved Word: ABSOLUTE Assembler () FAR INDEX FORWARD
Some Turbo Pascal statement

Statement is the command to work pascal programs. Statement lies in the declaration statement with reserve word preceded by BEGIN and ends with the word END reserve. The end of each statement ends with a semicolon [;]. Statements in the Pascal language statements consist of statements of functions and procedures that have been provided as the standard Turbo Pascal command.
1. Statements that are used for input / outputs.

# Read / readln [procedure]. This command is used to enter [input] data through the keyboard into a variable.
Syntax: Read / readln (x); (remember, always end with a semicolon [;]) Description: x = variable. Read = in this statement does not move the cursor position to the next line. Readln = on this statement positions the cursor will move to the next line after the input.
# ReadKey [function]. To read a character from the keyboard. The resulting data type is char. Syntax: ReadKey;
# Write / WriteLn [procedure]. Used to display the contents of a variable value on the screen. Syntax: Write / WriteLn (x); Description: x = variable. Write / WriteLn = statement is used to print variable into the monitor Example: Input program; Uses Crt; Var nm: String; NPM: String; Begin Clrscr; Writeln ( 'enter your name and NPM'); Writeln ('------------------------------'); Write ( 'Your name:'); Readln (nm); Writeln ( 'NPM you:'); Readln (NPM); End. When executed the results are: enter the name and NPM ------------------------------ Your name: (on input) NPM you: (in input)
2. Statements that are used for setting the location of the screen.
# Clrscr [procedure]. This command is used to clean the screen. syntax: clrscr; [Clear screen]
# Gotoxy [procedure]. To place the cursor position on the screen. Syntax: gotoxy (X, Y: Byte); Description: X = X-axis (horizontal position) Y = Y-axis (vertical position)
# DelLine [procedure]. To delete a row at the cursor position and raise the lines underneath. Syntax: DelLine;
# InsLine [procedure]. To insert a line at the cursor position and move down the line displays below it. Syntax: InsLine;
# Delay [procedure]. To stop the moment the program. Syntax: Delay (MS: Word); Description: MS = variable size in milisecond time. Example: Display Program; Uses Crt; Var x: Char; Begin Clrscr; Gotoxy (35.10); writeln ( 'I Love Dinda'); Write (wait a minute ...!!'); Delay (5000); InsLine; Gotoxy (35.11); writeln ( 'Baby sehatku'); Gotoxy (01.13); writeln ( 'Press Enter'); Delay (1000); Gotoxy (15.12); DelLine; Read (x); End. The result is: I Love Dinda Babies sehatku wait a minute ...!! Press Enter!
3. Statements used to manipulate strings.
# CONCAT [function]. To combine 2 or more string variables. Syntax: CONCAT (s1 [, s2 ,..., sn]: String): String; example: concat ( 'ABC', 'DEF') (ABCDEF)
# Copy [function]. Taking one or more characters from a string. Syntax: Copy (S, Index, Count): String; Description: S = a string (string). Index = initial position we will take a few characters (integer) Count = number of characters that will be taken (integer).
# Delete [procedure]. Delete some characters from a string. Syntax: Delete (S, Index, Count); Description: Copy of the same statement.
# Insert [procedure]. Insert one or more characters into a string. Syntax: Insert (Source, var S, Index); Description: Source = source string for the inserted (string) var S = string destination string will be inserted by Source (string) Index = start position (integer).
# Length [function]. Long value from a string (the number of characters in the string). Syntax: Length (S); Description: S = string Length (S) produces an integer value.
# Pos [function]. Finding the position of a part of string (substring) within a string. Syntax: Pos (substr, S); (generate byte value) Description: substr = substring to search for position in a string S. If the value 0 means the value of the search string does not exist.
# Str [procedure]. Changing the numerical values into string values. Syntax: Str (N, S); Description: N = integer data types, S = data type of string.
# Val [procedure]. Changing the string value into a numeric value. Syntax: Val (S, N, P); Description: S = value of the string, N = value of real, P = position wrong. Value string must contain numbers, plus or minus, if it does not mean error and error location indicated by the position of one variable. If true, then the variable value tsb = 0 (zero).
# UpCase [function]. Providing capital of the argument. Syntax: UpCase (S); Description: F = variable of type character. Example: Man_String Program; Uses Crt; Var s: String; l: Integer; h: String; Const a = 'Dinda'; b = 'Baby'; c = 'Sehatku'; Begin Clrscr; s: = CONCAT (a, b, c); Writeln (S); Insert ( '&', s, 6); Writeln (s); Delete (s, 7.7); Writeln (S); h: = Copy (s, 1.5); Writeln (h); l: = Length (s); Writeln ( 'The length of string S:', l); Writeln ( 'Position' Healthy "on the value of S: ', POS (' Healthy ', s)); END. The result is: DindaBayiSehatku Dinda & Sehatku baby Dinda Sehatku Dinda The length of the string S: 16 The position of "Healthy" on the value of S: 7th
4. Statements for arithmetic calculations.
# Abs [function]. Absolute value of an argument. Syntax: ABS (x);
# Arctan [function]. Gives the value of the arctangent function of the calculation goniometry. Syntax: arctan (x); 'where x can be real or integer type and will produce real-type value. "
# Cos [function]. Gives the value of the cosine function. Syntax: Cos (x);
# Exp [function]. Calculate the rank value of the number e (natural numbers), in the amount of x. Syntax: Exp (x); 'x can be real or integer type and will produce real-type value. '
# Frac [function]. To get the value of a fractional number. Syntax: frac (x); 'type of x the same as above. '
# Int [function]. Integer value (whole number) of a variable by removing the numbers behind the comma. Syntax: Int (X);
# Ln [function]. Used to calculate the value of natural logarithm (natural logarithm) of the value of x. Syntax: Ln (x);
# Sin [function]. Gives the value of sinus function. Syntax: Sin (x);
# Sqr [function]. Used to calculate the rank value of an integer square. Syntax: Sqr (x); This type of x can be either real or integer. And the result will be similar to the type of x.
# Sqrt (function). Used to calculate the value of the root of a number. Syntax: sqrt (x); Example: Arithmetic programs; Uses Crt; Var X: Real; Begin Clrscr; Write ( 'Enter the value of X ='); Readln (x); If x <0 Then x: = Abs (x) is; Writeln ( 'Value of X =', x: 5:2); Writeln ( 'Value eksponentialnya =', EXP (x): 9:3); Writeln ( 'Value = natural logarithm', LN (x): 9:3); Writeln ( 'Value integernya =', INT (x): 5:2); Writeln ( 'Value fraksionalnya =', frac (x): 5:2); Writeln ( 'The value of X raised =', SQRT (x): 9:3); Writeln ( 'The value of X rooted =', SQRT (x): 9:3); Write ( 'Value of X if included in'); Writeln ( 'functions Sin, Cos, Tangen:'); Writeln ( '- Sinus =', Sin (x): 9:3); Writeln ( '- cosines =', Cos (x): 9:3); Writeln ( '- Tangen =', arctan (x): 9:3); End. Result: enter the value of X = -2.5 Value of X = 2:50 Value eksponensialnya = 12.182 Value natural logarima = 0.196 Value integernya = 2:00 Value fraksionalnya = 0:50 The value of X raised = 6250 The value of X rooted = 1581 The value of X if included in the Sin function, Cos, Tangen: - Sinus = 0598 - Cosine = -0801 - Tangen = 1190
5. Statements for the transfer of the value of a variable.
# Chr [function]. Changing the value of the byte to character form according to the ASCII code. Syntax: Chr (x); Description: x type byte example: writeln (Chr (61)); result: a
# Ord [function]. Changing the value of a variable from form to form Longint character. Syntax: Ord (x) is; Keteranagn: x of type char example: WriteLn (Ord ( 'B')); results: 42
# Round [function]. Made up of real type data into the data type Longint. Syntax: ROUND (x); Description: If the value of fractions <0.5, then rounded down. If the value of fractions> 0.5, then rounded up. example: writeln ('10 / 3 rounded = ', ROUND (10 / 3)); result: 10 / 3 rounded = 3
# TRUNC [function]. Rounding down the real type of data to the data type Longint. Syntax: Trunc (x); example: writeln ('20 / 3 rounded down = ', Trunc (20 / 3)); result: 20 / 3 rounded down = 6
6. Statements to manipulate the data.
# Pred [function]. Providing value before the value of the argument in the order in ASCII. Syntax: Pred (x);
# Succ [function]. Value after the argument values in the order in ASCII. Syntax: Succ (x);
# Inc. [function]. Add (increments) the value of a variable. Syntax: Inc (x, i); (i> = 1)
# Dec [function]. Reduce (decrements) the value of a variable. Syntax: DEC (x, i); (i> = 1)
Example: Man_Data program; Uses Crt; Type day = (hr0, hr1, hr2, hr3, hr4, hr5, hr6, hr7) Var urutanhr: days; Const namahr: Array [hr1 .. hr7] of String [6] = ( 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'); Begin Writeln ( 'Code Name Day); urutanhr: = hr0; While Urutanhr
Begin urutanhr: = Succ (urutanhr); Write ( 'day', Ord (Urutanhr): 2, 'is'); Writeln (namahr [urutanhr]); End; End. results are: List Name Day Day 1 is Monday Day 2 is Tuesday day 3 is Wednesday Day 4 is Thursday Day 5 is Friday Day 6 is Saturday Day 7 is Sunday
7. Additional statements (color, sound and window).
# Textcolor [procedure]. To set the color of the characters on the screen. Syntax: textcolor (color: Byte); Note: to view color options in Turbo Pascal books you have. List textColor: (2nd) Green Young (3) Green vanished (4) Red (5) Old Purple (6) Yellow (7) White (8) Deep Blue (9) Blue Clear (10) Green Young (12) Pink (13) Purple Bright (14) Yellow Young (15) Purple Pupus (16) Black
List textColor with Blink: (17) Deep Blue (18) Green Young (19) Pupus Green (20) Red (21) Purple Old
# TextBackGround [procedure]. To set the background color of the screen characters. Syntax: TextBackGround (Color: byte);
# Window [procedure]. To create a window (window), located on the screen. Syntax: Window (x1, x2, y1, y2: Byte); x1, x2 = upper left coordinates with the maximum value in accordance with the display mode. y1, y2 = coordinates of the lower right with a maximum value in accordance with the display mode.
# TextMode [procedure]. To set the screen width, or 80 columns 40 columns. Syntax: TextMode (Mode: byte); Default = C80
# Sound [procedure]. To activate the sound (beep) on the internal speakers. Syntax: Sound (Hz: word); To mengnonaktifkannya, use NoSound statement. Example: Layar2 Program; Uses Crt; Begin Clrscr; Window (5,5,20,75); TextBackGround (Red); 'you can also use the number (4) Textcolor (Yellow); Sound (220); Gotoxy (10.7); Writeln ( 'I Love Dinda'); Gotoxy (11.7); Writeln ( 'Baby Sehatku'); NoSound; End. As an exercise of the theories you have learned above, you try doing the questions below.
Solved 1. Problem I Make the following programs by using the command Window display, textcolor, textColor Blink, Textbackground, gotoxy, and Sound to enhance the display. 1. Changing degrees of temperature, from degrees Celsius to degrees Fahreinheit and Reamur (Celsius degrees is inputted) 2. Calculating the area and circumference of the circle, the radius is known (input). 3. Counting and Around the triangle area is known to any of three sides. 4. Finding value of sinus, cosines, and Tangen inputted angle. 5. Finding the root and the square of a value (input value). 6. Looking for round and fractional values of a value is entered via the keyboard (input). Fractional values are rounded to 3 digits behind the comma (,). 7. Display your name and NPM in the window, and is located in the middle of the screen. 8. See the writings of 'I Love Dinda' in the window at the top right corner with a window size equal to the text. 2. Problem II Make the program in question type I (no. 1-6) with a display using 2 window. The first window is used for the input value. The second window for the results of the program (output). 3. Problem III 1. Make a program to combine 2 pieces of inputted word. Every word must be inputted in the window and the results are on a different window. 2. Make a program to randomly display window with a different color.

0 comments: