Console Application
Before we go further with visual programming, it is important to understand the basic element of
To make a console application, choose File – Close All (if thee is still a form in IDE). Then choose File – New, select Console Application.
Declare constants and variables after uses SysUtils;
const
length : integer = 12;
width : integer = 8;
var
area : integer;
Insert user code between begin …. end.
area := length*width;
writeln('Length of rectangle = ',length);
writeln('Width of rectangle = ',width);
writeln('The area = ',area);
readln;
The complete codes of Project1.dpr :
program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils;
const
length : integer = 12;
width : integer = 8;
var
area : integer;
begin
// Insert user code here
area := length*width;
writeln('Length of rectangle = ',length);
writeln('Width of rectangle = ',width);
writeln('The area = ',area);
readln;
end.
Run the program, and the result is :
The last code readln; is for delaying program until you press Enter button.
Comment
// Insert user code here is an example of comment. Comment can be written in three ways :
- Written between { }
- Written between * *
- Begun with // like the example above
Assigning a value to a variable
From the program above, we assign a value to area variable using assignment operator :=. The syntax is :
variable := value;
so the code is :
area := length*width;
Go to Previous Tutorial or Next Tutorial
blog ini memang kerenz tutorialnya yang nichenya unik tentunya memiliku pangsa tersendiri, tapi ya harus sabar karena tutorial yang semacam ini memang peminatnya kurang begitu banyak, karena banyak orang yang setba praktis he he he...terimakasih atas pencerahannya.
ReplyDeletemoga sukses selalu
aq g ngerti wes bahasa pemropograman gini, ilmu q belum nyampe'
ReplyDelete@Pakde : Thank you for your encouragement.
ReplyDelete@Rizky : We can learn together then.
s The best and a lot of secret drop-shipping suppliers in the world which will provide your products globally available for you directly to your customers doors. Also get the best drop-shipping manufacturer on your organization.
ReplyDelete