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

Assignment Help:

 /*
 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:-"<  }


Related Discussions:- Program to input 2 date & produce a new date - c++ program

Compiler design, Compiler Design - Limit In The Method Instructions

Compiler Design - Limit In The Method Instructions

Dynamic constructor, dynamic initialization of object using constructor in ...

dynamic initialization of object using constructor in C++

Define some important point for bit fields with structures, Define some Imp...

Define some Important Point for bit fields with structures? Only n lower bits will be assigned to an n bit number thus type cannot take values larger than 15 (4 bits long)

Singly linked list, For this program you will add and test 2 new member fun...

For this program you will add and test 2 new member functions to the IntSLList class posted on the website. The two member functions are: insertByPosn(int el, int pos) Assuming t

C program for multiplication table , C Program for MULTIPLICATION TABLE ...

C Program for MULTIPLICATION TABLE   main() {           int a, b=1, c, d;           char ch;           clrscr();           while(ch!='n')           {

''c'' programme, Write a ''C'' program to accept any 3 digit integer number...

Write a ''C'' program to accept any 3 digit integer number from the keyboard and display the word equivalent representation of the given number.

Algorithem, algorithem of compound interest

algorithem of compound interest

Decode the code, smugglers transfer the messages from one to another by usi...

smugglers transfer the messages from one to another by using the mobile

#title prime number or not, to find prime numbers upto any number say "n" e...

to find prime numbers upto any number say "n" entered by user

Random card generator, i need a program that generates this output: The hig...

i need a program that generates this output: The highest card wins! Suit Order is: clubs, diamonds, hearts and spades The computers card is the 5 of Spades. The player’s card is t

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd