Program to input 2 date & produce a new date - c++ program, C/C++ Programming

 /*
 THIS PROGRAM IS TO ASK USER TO INPUT TWO DATE & PRODUCE A NEW DATE

 */
#include
#include

struct date
 {
  int dd;
  int yy;
  int mm;
 };
date add(date d1,date d2)
   {
  date temp;
  temp.dd=d1.dd+d2.dd;
  temp.mm=d1.mm+d2.mm;
  temp.yy=d1.yy+d2.yy;
   if(temp.dd>=30)
     {
     temp.dd-=30;
    temp.mm++;
     }
  else
   if(temp.dd>=31)
     {
    temp.dd-=31;
    temp.mm++;
     }
  else
   if(temp.dd>=28)
      {
    temp.dd-=28;
    temp.mm++;
      }
 if(temp.mm>=12)
      {
     temp.mm-=12;
     temp.yy++;
      }
   return temp;
   }
void main()
  {
  clrscr();
  date d1,d2,ans;
  cout<<" enter the 1st date (dd/mm/yyyy) ";
  cin>>d1.dd;
  cin>>d1.mm;
  cin>>d1.yy;
  cout<<" enter the 2nd date (dd/mm/yyyy) ";
  cin>>d2.dd;
  cin>>d2.mm;
  cin>>d2.yy;
  ans=add(d1,d2);
  cout<<" new date:-"<  }

Posted Date: 10/22/2012 4:38:33 AM | Location : United States







Related Discussions:- Program to input 2 date & produce a new date - c++ program, Assignment Help, Ask Question on Program to input 2 date & produce a new date - c++ program, Get Answer, Expert's Help, Program to input 2 date & produce a new date - c++ program Discussions

Write discussion on Program to input 2 date & produce a new date - c++ program
Your posts are moderated
Related Questions
#question write a prog c & cpp

Description - The TR-069 CPE WAN Management Protocol (CWMP) is a protocol that was created by the Broadband Forum (formally the DSL Forum) which sets out a common method for CPE de

Need someone to look over my assignment for correctness and make any necessary changes.

This program requires the use of a windows box, no console applications are allowed. Prepare for Christmas now.  Each year, Reindeer Gift Emporium publishes a Christmas price list

#padovan string in java   program in java // aakash , suraj , prem sasi kumar kamaraj college program 1 : package test.padovanstring; public class PadovanStrin

#questiowrite a program to calculate e^x

overload assignment opertor to assign the data of one object to anthor

Overloading Unary Operators class sign {int a,b,c; public: sign(){}; sign(int,int,int); void putdata(void); void operator-(); }; void sign::operator-() {a=

Here is a short program. It prints out the value of a variable "x". Ernie and Bert disagree about what will be printed: Ernie says, the value gets changed in "changeX" so it will p

Q: How can Define an Array? An Array is defined in much the alike manner as ordinary variables except that every array name must be accompanied by a size specification (that is