IT2240_U5A1_Bryant_part_1.c - Randall Bryant IT2240 U05A1 Part 1 Rev 1 Write a program that asks the user for a date in the format mm\/dd\/yyyy using a

IT2240_U5A1_Bryant_part_1.c - Randall Bryant IT2240 U05A1...

This preview shows page 1 - 2 out of 2 pages.

/* Randall Bryant - IT2240 - U05A1 - Part 1 * 11/05/2018 Rev. 1 Write a program that asks the user for a date in the format mm/dd/yyyy, using a custom struct to store the date information entered in memory. The program should call a custom function that adds seven days to the user's date, passing in the data in and out of the custom function using the custom struct for the dates. The program should then print out the original date entered and the date one week later. */ //Define constances #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <stdbool.h> //Define structure for our date struct date { int month; int day; int year; }; //Function to check if the year entered is a Leap year bool leapYear(int year) { if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) return true; else return false; } //Function to find the amount of days in the month int days_in_month(struct date d) { int max_days; //Check if month entered is February if (d.month == 2) { if (leapYear(d.year) == true) max_days = 29; else max_days = 28; } //Determind the days for the rest of the months else if (d.month == 4 || d.month == 6 || d.month == 9 || d.month == 11) // Checks for months with 30 maximum days
Image of page 1
Image of page 2

You've reached the end of your free preview.

Want to read both pages?

  • Spring '13
  • Enter key, Randall Bryant

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes