Comments

Tuesday, August 27, 2013

Days month year converter

Posted by at 3:47 AM Read our previous post


Object:
Convert the days Weeks and years

Source Code:

#include <iostream>
using namespace std;
         
class weeks
{
public:
       int *days(int day,int month,int year)
       {
              int answers[3];
             

              if(day>30)
              {
              day=day-30;
              month=month+1;
              }

              if(month>12)
              {
                     month=month-12;
                     year++;
              }
      
              answers[0]=day;
              answers[1]=month;
              answers[2]=year;
             
              return answers;
       }


};
void main()
{
       weeks week;
       int *ptr,days,months,years;

       cout<<"Enter days"<<endl;
       cin>>days;
       cout<<"Enter MOnth"<<endl;
       cin>>months;
       cout<<"Enter Year"<<endl;
       cin>>years;

       ptr=week.days(days,months,years);

       cout<<"Days : "<<ptr[0]<<"Month : "<<ptr[1]<<"Year : "<<ptr[2];
}



Output:

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Popular Posts

Labels

© Codepirate is powered by Blogger - Template designed by Stramaxon - Best SEO Template