Programalama > PASCAL

Etiketler: decision, pascal

Ort. 0
Puan ver:
var iNumber : Integer;
begin
//some value must be 
//assigned to iNumber here!
if iNumber = 0 then
  ShowMessage('Zero value encountered!');
end;

var iNumber : Integer;
begin
//some value must be 
//assigned to iNumber here!
if iNumber = 0 then
begin
  ShowMessage('Zero value encountered!');
  Exit; // exit from the current procedure
end;
//if iNumber is 0 the folowing 
//code will never be executed
ShowMessage('Nobody likes 0, ha!');
end;

var iNumber : Integer;
begin
//some value must be 
//assigned to iNumber here!
if iNumber < 0 then
 begin
  //statements ...
  ShowMessage('Your number is negative!');
  //statements ...
 end
else
 begin
  //statements ...
  ShowMessage('Your number is positive or zero!');
  //statements ...
 end;
end;

var iNumber : Integer;
begin
if iNumber = 0 then
  begin
    ShowMessage('Zero number not allowed!');
    exit;
  end
else
//no need to use begin-end here
  if iNumber < 0 then
    ShowMessage('Your number is negative!')
  else
    ShowMessage('Your number is positive!');
end;

var iNumber : Integer;
begin
//some value must be 
//assigned to iNumber here!
begin
case iNumber of
 0:
ShowMessage('Zero value');
 1..10 :
ShowMessage('Less than 11, greater than 0');
 -1, -2, -3 :
ShowMessage('Number is -1 or -2 or -3');
 else
ShowMessage('I do not care');
end;
end;



Yorumlar                 Yorum Yaz
Bu hazır kod'a ilk yorumu siz yapın!
KATEGORİLER
ASP - 240
ASP.NET - 24
C# - 75
C++ - 174
CGI - 8
DELPHI - 247
FLASH - 49
HTML - 536
PASCAL - 246
PERL - 11
PHP - 160
WML - 9
XML - 2
Copyright © 2002 - 2024 Hazır Kod - Tüm Hakları Saklıdır.
Siteden yararlanırken gizlilik ilkelerini okumanızı tavsiye ederiz.
hazirkod.com bir İSOBİL projesidir.