write and execute a program wich takes three integers as input representing a date as day , month , year,and print out the number day, month, year for the following days date typical input : 28 2 1992 typical output : date following 28: 02:1992 is 29:02:1992.
Answers
Answer:
Explanation:
efine a structure date containing three integers -day,months and year. Write a program using functions to read data, to validate the data entered by the user and then print the date on the screen.
For example,if you enter 31/6/2007 is invalid as June does not has 31 days, similarly if you enter 25/13/2000 then it is invalid month as month ends with 12(1-12. jan to dec). The threshold value for year is 3000 (Invalid Year). Valid year: 0000-2999
Using the structure definition of the above program, write a function to increment that .Make sure that the incremented date is a valid date. Modify the above program to add a specific number of days to the given date.Write a function to compare two date variable.
Output:
33 12 1989 - Invalid Day
31 12 3000 - Invalid Year
31 13 1989 - Invalid Month
25 12 1989- New Date=26 12 1989
Mandatory:
1. Create a Structure as "Date"
2. Create three data members as date(int), month(int), year(int)
3. The structure variable for "Date" structure is "D"
Note: The structure variables, data members and structure name are CASE Sensitive.
Follow the same case mentioned in the mandatory
#include <stdio.h>
int main() {
int ndays, y, m, d;
printf("Input no. of days: ");
scanf("%d", &ndays);
y = (int) ndays/365;
ndays = ndays-(365*y);
m = (int)ndays/30;
d = (int)ndays-(m*30);
printf(" %d Year(s) \n %d Month(s) \n %d Day(s)", y, m, d);
return 0;
}