//Date : September 26, 2014 Firday
//Email : Oursharingclub@163.com
//Tool : Dev C++
//Language : C++
//Function : Check Even and Odd Number
#include <iostream>
#include <ctype.h>
#include <windows.h>
using std::cout;
using std::cin;
//------Check Even or Odd function and Menu function
bool CheckEvenOrOdd( int number );
void Menu( void );
//------main function -------
int main( void )
{
Menu();
return 0;
} //End of main function
//----Even or Odd function ,Menu function
bool CheckEvenOrOdd( int number )
{
// Even number ,return 1; else return 0
return ( ( number% 2== 0 ) ? 1: 0 );
} //End of CheckEvenOrOdd functin
void Menu( void )
{
char number;
char letter;
system( "color A" ); // Only change the text color
cout<< "\n\t*******Even and Odd number solver *******";
cout<< "\n\n";
cout<< "\t\t Enter a number : ";
cin>> number;
if( isdigit( number )== 0 )
{
cout<< "\n\n\t\t Sorry, "<< number<< " is not digit!!!\n";
cout<< "\t\t Try again!";
Menu();
}
if( CheckEvenOrOdd( number) )
{
cout<< "\n\t\t "<< number<< " is an Even numuber ";
}
else
{
cout<< "\n\t\t "<< number<< " is an Odd number ";
}
system( "color C" ); // Only change the text color
cout<< "\n\n\t\t Do you want to continue( Y/N ): ";
cin>> letter;
if( toupper( letter )== 'Y' )
{
system( "cls" ); //clear screen
Menu();
}
else
{
exit( 1 );
}
return ; // returns nothing
} //End of Menu function
0 Comment:
Post a Comment