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
write a program to find the area under the curve y=f(x) between x=a & x=b

A: No. There is nothing you can do in C++ which you cannot do in C. In spite of everything

Write a program to calculate the average of ten numbers       #include stdio.h     /* Only this header is needed since only IO are used */     void main()     {          char


Requirements: 1.  This assignment as well as other assignments in this class must be finished on Windows operating system. 2.  Zip your program and submit the zip file on ANG

A: The simplest instance of a smart pointer is auto_ptr that is included in the standard C++ library. Auto Pointer only takes care of Memory leak & does nothing regarding dangling


Implement a Algorithm to verify if the link list is in Ascending order? A: template bool linklist::isAscending() const{ nodeptr ptr = head; while (ptr->_next)

how to make a diamond from steric

Question: (a) Explain the function fseek(). Using an appropriate example, write the full syntax for this function. (b) Write a C or C++ program that will perform the follo