Selasa, 24 Mei 2011

PRINTING TO SCREEN AND USE OF VARIABLE


Ok, now we will learn how to display text on the screen and use variables. Consider the example below:

1: Work First Program;
2: uses crt;
3: var name: string;
4: Begin
5: write ('Enter your name:'); readln (name);
6: clrscr;
7: write ('Hi', name, 'how are you doing? ");
8: End.

In the row-3 declared variable name of type string. Because of a string, variable names can accommodate input from the user in the form of words and numbers. For more details about the types of data types see table below. Make no mistake declare type variables.

Now consider the rows of the 5th. Write function is to print a sentence or an existing variable contents to the screen. So that is printed is the "Enter your name:". Furthermore there readln command. What is its function? readln it serves to accommodate (store the results of user input) and stored in the variable name. So now the variable name the same value that you typed.

In the 7th row on the screen will be printed "dijas Hi how are you?" (That's if the name entered dijas). To display the contents of the variable is written: "write (name);". Meanwhile, when the form of a fixed text, such as the 5th line (using '(quote)).

What is different write and Writeln? write functions to print on the screen and the cursor position is row, too. While Writeln will move kebaris new. Note Examples

1: Begin
2: write ('Hi ...'); write (' How are you doing? ");
3: Writeln;
4: Writeln ('Hi ..') Writeln ('How are you doing? ");
5: End.

So the output that appears is:
Hi ... How are you?
Hi ...
How are you?

Definitely not? So the function "ln" on Writeln is to move kebaris new. Its function will be the same when placed in a read. Yup finished the first tutorial as well ...

Frequently Used Data Types in Pascal
Char -> holds only one character
string -> accommodate more than one character
Boolean -> only have two values ​​True or False
Integer -> -32 768 s / d 32 767 (can not decimal)
longint -> -2147483648 s / d -2147483648 (can not decimal)
read -> 2.9 x 10-39 s / d 1.7 x 1038 (to accommodate decimals)

Tidak ada komentar:

Posting Komentar