In C programming. Program must use user defined functions and rely only on if, e
ID: 3675074 • Letter: I
Question
In C programming. Program must use user defined functions and rely only on if, else, and else if. Use of for, loops, and arrays are not allowed. Thank you in advance!!
Problem: In recent years the start of spring break has taken place 9 weeks after the start of the spring semester. Given a month, day, and year determine the date that occurs 9 weeks later.
Example Execution #1 (this school year): Enter month number: 1 Enter day number: 11 Enter the year: 2016 Original Date: 1/11/2016 Future Date: 3/14/2016
Example Execution #2 (next school year): Enter month number: 1 Enter day number: 9 Enter the year: 2017 Original Date: 1/9/2017 Future Date: 3/13/2017
Example Execution #3 (dates can span years): Enter month number: 12 Enter day number: 31 Enter the year: 2015 Original Date: 12/31/2015 Future Date: 3/3/2016
Example Execution #4: Enter month number: 10 Enter day number: 30 Enter the year: 2014 Original Date: 10/30/2014 Future Date: 1/1/2015
Explanation / Answer
#include<iostream.h>
#include<time.h>
int main()
{
int year,int month,int dayl
cout<<"enter the year,month and day"; /* to enter a given data*/
cin>>day>>month>>year;
/*9 weeks=9*4=36 days ,, we will add this to the number of days here */
struct tm p = { .tm_year=year-1900, .tm_mon=month-1, .tm_mday=day };
/* modify */
p.tm_mday += 36
mktime(&p);
/*This will show a given data after 36 days from the given input date */
printf("%s", asctime(&p));
return 0;