In this project, we Add the given number of days to a given date and display the new date using C++ Language.
In this project, we can see in the member function adddte() that on adding the specified number of days to the date, if the day value exceeds the value 31 for the months: 1,3,5,7,8,10 and 12 which consists of 31 days, we subtract the value:31 from the day value and increment the month value by1.
Similarly, if the day value exceeds the value 30 for the months: 4,6,9,11 which consists of 30 days, the day value is reduced by 30 and the month value is incremented by 1.
If the year is a leap year and the month is 2 i.e. Feb, and after adding the specified number of days, the day value exceeds value 29, the day value is reduced by 29 and the month value is incremented by 1. if the year is not a leap year and the month is 2 and it exceeds the value 28, then the day value is decremented by 28 and month value is incremented by 1
Also, we check that if the value of the month exceeds the value 12, then value 12 is subtracted from the month value and the year value is incremented by 1
Submitted by Shohrat (sanamura)
Download packets of source code on Coders Packet