Sep 26, 2014

Check Leap Year

2:37 AM Posted by Unknown , No comments
//Auther   : Walter
//Date     : September 26, 2014 Firday
//Email    : Oursharingclub@163.com
//Tool     : Dev C++
//Language : C++
//Function : Check Leap Year

#include <iostream>
#include <windows.h>   // for system( )
#include <ctype.h>   // for toupper()


using std::cout;
using std::cin;

//----- menu and check function---

void Menu( void );   //The start menu
bool CheckLeapYear( int year );   // check leap year ?


//-----Main function--------
int main( void )
{
Menu();

return 0;
} // End of mian function


//---------menu and check function
void Menu( void )
{
int year;
char letter;

system( "cls" );  //clear screen
system( "color FC" );  // change the text color and backgroud color

cout<< "\n  ************ Leap Year Solver ************";
cout<< "\n\n";

cout<< "\t\t Enter Year: ";
cin>> year;

cout<< "\n\n";

if( CheckLeapYear( year ) )
{
  cout<< "\t\t "<< year<< " is a Leap Year. \n\n";
}
else
{
  cout<< "\t\t "<< year<< "is not a Leap Year. \n\n";
}

cout<< "\t\t Do you want to continue( Y ): ";

cin>> letter;

if( toupper( letter )== 'Y' )
{
Menu();
}
else
{
   exit( 1 );
}

return ;
}//End of Menu function


bool CheckLeapYear( int year )
{
if( ( year% 400== 0 ) || ( year% 4== 0 && year% 100!= 0 ) )
{
   return 1;
}
else
{
   return 0;
}
}  // End of Check function



ScreenShot:




0 Comment:

Post a Comment