IsLeapYear (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example requires a button and a text edit. When you press the button, a message indicates whether the year specified in the text edit is a leap year.

Code

bool __fastcall IsThisLeapYear(int year)
{
  return IsLeapYear(year);
}

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  int year = StrToInt(Edit1->Text);
  if (IsThisLeapYear(year))
	ShowMessage(Edit1->Text + " is a leap year.");
  else
	ShowMessage(Edit1->Text + " is not a leap year.");
}

Uses