Página 1 de 1

Verificar número par ou ímpar em Delphi

Enviado: terça abr 01, 2025 6:58 am
por JosephsIc
unit Unit1;

interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Classes,
Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
public
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
Numero: Integer;
begin
Numero := StrToInt(Edit1.Text);

if (Numero mod 2 = 0) then
ShowMessage('O número é PAR')
else
ShowMessage('O número é ÍMPAR');
end;

end.


=============================================================

https://www.nasciweb.com.br