u

Sunday, 3 June 2012

C++ Program to implement leap year checking using functions

C++ Program to implement leap year checking using functions

#include<iostream.h>
#include<conio.h>

void d(int ,int ,int );   //prototype of a funtion

void main()

{
clrscr();
    int x,y,z;

   cout<<"Enter day : "; cin>>x;
   cout<<"Enter  month : ";cin>>y;
   cout<<"Enter year : ";cin>>z;

      d(x,y,z);       //function calling
   getch();
  }

  void d(int x,int y,int z)     //funtion definition
{

  switch (y)
  {

  case (1):cout<<"junuary";break;
  case (2):cout<<"fabruary";break;
  case (3): cout<<"march";break;
  case (4):cout<<"april";break;
  case (5):cout<<"may";break;
  case (6):cout<<"June";break;
  case (7):cout<<"july";break;
  case (8):cout<<"August";break;
  case (9):cout<<"september";break;
  case (10):cout<<"October";break;
  case (11):cout<<"november";break;
  case (12):cout<<"december";break;
  default:cout<<"Invalid month instruction";

  }

if (x>=32||x<=0)              //Important point  for day instruction
cout<<"Invalid day instruction";
else
cout<<x<<",";

   if (z<=0)
   cout<<"invalid year input"<<endl;
else
   cout<<z<<endl;

    if(z%4==0) 

    cout<<z<<"is a leap year"<<endl; 
  else 
    cout<<z<<"is not a leap year"<<endl; 


  } 

0 comments:

Post a Comment

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More