Saturday, 18 February 2017

C++ program of knowing date of birth using structure

In this program we will how to enter date using structure and knows the date of birth of someone


//Code starts
#include<iostream>
#include<conio.h>

using namespace std;

class date{

 private:
  int day,month,year;
 
  public:
   void setday();
   void setmonth();
   void setyear();
  
   int getday();
   int getmonth();
   int getyear();
  
   void display();
  
};

void date::setday()
{
 cout<<"Enter day ";
 cin>>day;
}

void date::setmonth()
{
 cout<<"Enter Month ";
 cin>>month;
}

void date::setyear()
{
 cout<<"Enter Year ";
 cin>>year;
}

int date::getday()
{
 return day;
}

int date::getmonth()
{
 return month;
}

int date::getyear()
{
 return year;
}


void date::display()
{

 cout<<day<<"-"<<month<<"-"<<year<<endl;

}

int main()
{
 date d1;

 d1.setday();

 d1.setmonth();

 d1.setyear();

 d1.display();


  if(d1.getday()==25&&d1.getmonth()==12)
 {
  int age;
 
  age=d1.getyear()-1876;
  cout<<"Today is Quaid_E_Azam's "<<age <<"th Birthday";
 }
 
 getch();
}

//code ends





Share:

0 comments:

Post a Comment