c++ programming

posted by .

Write a program that determines the day number (1 to 366) in a year for a date that is provided as input data. As an example, January 1, 2011 is day 1. December 31, 2010 is a day 365. December 31, 2012 is day 366, since 2012 is a leap year. A year is a leap year if it is divisible by four, except that any year divisible by 100 is a leap year only if it is divisible 400. Your program should accept the month, day and year as integers.

  • c++ programming -

    You'll need to first determine if the year is a leap year by the rules given above:

    int isLeap(int year){
    int leap=0;
    if(year divisible by 4)leap=1;
    if(year divisible by 100)leap=0;
    if(year divisible by 400)leap=1;
    return leap;
    }

    Then make an array of cumulative number of days of the previous month, example:
    int cndpm(int n){
    // n=month, 1=january, ...12 = december
    int count[12];
    count[0]=0;
    count[1]=31;
    count[2]=59; // 60 for leap year
    ...
    }
    So for March, cndpm(2) will return the total number of days before March 1st.

    I'll let you think about the rest, and post if you need further help.

  • c++ programming -

    LOL I ARE SO COOL

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. Computer Programming

    I must write a program using Java that calculates the amount a person would earn over a period of time if his or her salary is one penny the first day, two pennies the second day, and continues to double each day. The program should …
  2. Programming

    Design a program in pseudocode that calculates the amount of money a person would earn over a period of time if their salary is one penny the first day, and then doubles each day. The program should ask the user for the number of days. …
  3. math 4 grade

    Some poeple believe that Jan 1,2000is the first day of the 21st century.Other poeple beleive that the honor belongs to the Jan 1,2001.But everyone should agree that Jan 1,2002 is the first"sum-day" of the new century when you write …
  4. Algebra 2

    Question is about Step Functions:(between" " are all floor functions. The formula W=d+2m+"(3(m=1)/5)"+y+"y/4" -"y/100" + "y/400" + 2 gives the day of the month of the given date; m = the number of the month in the year with January …
  5. c++ programming

    Solve the following problem. Apply all the steps i.e decomposition, Flowcharting and Pseudo code. Also write C++ program. Design and Write an interactive program that computes the salary in Rupees of a part-time employee based on: …
  6. Logic

    Draw a flowchart for a program that reads a date in an 8-digit sequence (month, day, year) and determines if the date is a valid date. ignore leap year. Assume Feb has 28 days, and establish a table of days in a month so that you can …
  7. biology

    time day 0 day 1 day 3 day 4 day 5 day 7 count blank 7 10 5 14 9 8 low 45&49 64&70 62&69 75&79 80&82 68&72 high 45&49 72&78 100&112 180&195 250&267 208&226 Calculate the cell yield for the following data that were obtained using a …
  8. c programming , computer science

    1-Write a program that determines the day number (1 to 366) in a year for a date that provided as input data. As an example, January 1, 1994, is day 1. December 31, 1994, is day 365. December 31, 1996, is day 366, since 1996 is a leap …
  9. Java programming

    I have hard time doing this any help? Rewrite the definition of the method setdate and the constructor with parameters so that the values of month, day, and year are checked before storing the date into the data members. Add a method
  10. Trignometry

    In Philadelphia the number of hours of daylight on day t (t is the number of days after january 1) is modeled by the function L(t)= 12+2.83sin((2*Pi)/365(t-800) a. Which day have about 10 hours of daylight?

More Similar Questions