Still
in my blog at “We Are Knowledge”… Yhis blog having many IT knowledge from
dekstop programming until web programming.
Likely
this article to fill IT knowledge about dekstop programming, that is program
language “pascal”.
And
now.. Iwant givingyou knowledge about “IF in PASCAL”. Likely other program
language… in pascal also statement “”IF’
Ok..
let’s do read my article
Copy
this program then paste in your software likely "turbo pascal" :
Example 1:
uses crt;
var
a : integer;
label
10,20,30,40;
begin
clrscr;
writeln (' *** MENU OF
FOODS ***');
writeln;
writeln ('1. NASI GORENG
Rp. 8.000');
writeln ('2. NASI RAMES
Rp. 7.000');
writeln ('3. NASI UDUK
Rp. 5.000');
writeln;
write ('NUMBER
ORDER : ');
readln (a);
if a = 1 then
goto 10;
if a = 2 then
goto 20;
if a = 3 then
goto 30;
10:
writeln ('YOU ARE CHOICE
NASI GORENG');
writeln ('FEE Rp.
8.000');
writeln ('THANKS,..
PLEASE WAIT');
readln;
goto 40;
20:
writeln ('YOU ARE CHOICE
NASI RAMES');
writeln ('FEE Rp.
7.000');
writeln ('THANKS,..
PLEASE WAIT');
readln;
goto 40;
30:
writeln ('YOU ARE CHOICE
NASI UDUK');
writeln ('FEE Rp.
5.000');
writeln ('THANKS,..
PLEASE WAIT');
40:
readln;
end.
And
result :
If your input number 1
result :
writeln ('YOU ARE CHOICE
NASI GORENG');
writeln ('FEE Rp.
8.000');
writeln ('THANKS,..
PLEASE WAIT');
If your input number 2
result :
writeln ('YOU ARE CHOICE
NASI RAMES');
writeln ('FEE Rp.
7.000');
writeln ('THANKS,..
PLEASE WAIT');
if your input number 3
result :
writeln ('YOU ARE CHOICE
NASI UDUK');
writeln ('FEE Rp.
5.000');
writeln ('THANKS,..
PLEASE WAIT');
Note :::
for compile the program you use >> “alt + F9”
for runing the program
you must >> “ctrl + F9”
change all quotes (“ “)
or (‘ ‘), if you copy + paste
Logic :
Goto
>> statement goto
for move from statement to other statement
If
>> statement
conditional “if” true then working or looking for other conditional until “else”
Writeln
>> printing in output window
Readln
>> Inputing in output window
No comments:
Post a Comment