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
Abstract array - c program: AbstractArray::AbstractArray( int anUpper, int aLower, sizeType aDelta ) {     PRECONDITION( anUpper >= aLower );     lastElementIndex = a

A: Use p = new T[n] and delete[] p:   Fred* p = new Fred[100]; ... delete[] p; Any time you allocate an array of objects through new (generally with the [n] in the n

in this problem you are given a board in which some of the elements are placed..each element represent ancolor.fill the other elements in the board such that none of the adjacent e

Define the Data Types of c language? The C has a concept of 'data types' which are used to define a variable before its use and the definition of a variable will assign storage


Please give me a programming code of first & follow with c or c++ laqnguage .When anyone give me the programming code of first & follow please explain every lines with the help


how to get plus asterisk pattern

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

C program to add, average and deviation of numbers: void main() {                 int sum=0,a[10],i;                 float avg=0,dev,vari=0,var;                 pri