# c++ programming

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.

1. 👍
2. 👎
3. 👁
1. 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.

1. 👍
2. 👎
2. can you give me the whole source code? I will all the more learn from it and even practice from it all the more. Thanks

1. 👍
2. 👎

## Similar Questions

1. ### Programming

Write pseudocode to represent the logic of a program that allows the user to enter a value for hours worked in a day. The program calculates the hours worked in a five day week and the hours worked in a 252 day work year. The

2. ### Programming

Draw a flowchart or write pseudo code to represent the logic of a program that allows the user to enter values for the current year and the user’s birth year. The program outputs the age of the user this year. Preferably a

3. ### Math

A survey about the student government program at a school finds the following results. 190 students like the program 135 students think the program is unnecessary 220 students plan on running for student government next year. If a

4. ### intro to computer programming

Write a program that asks the user to enter the number of packages purchased. The program should then display the amount of the discount (if any) and the total amount of the purchase after the discount. Your program should use a

1. ### Math

Note: Enter your answer and show all the steps that you use to solve this problem in the space provided. A survey about the student government program at a school finds the following results: 190 students like the program 135

2. ### MATH

WRITE A SIMPLE BUT A COMPLETE FORTRAN PROGRAM TO COMPUTE THE AVERAGE OF SIX NUMBERS AND DISPLAY THE NUMBERS, SUM AND AVVERAGE. THE PROGRAM SHOULD TERMINATE WHEN ZERO IS ENTERED AS A NUMBER. THE PROGRAM SHOULD BE EDUCATIVE

3. ### Python programming Language

Assume S is a string of lower case characters. Write a program that counts up the number of vowels contained in the string S. Valid vowels are 'a', 'e', 'I', 'o', and 'u'. For example, if S='azcbobobegghakl' your program should

4. ### java programming

1. Time Calculator Write a program that asks the user to enter a number of seconds. • There are 60 seconds in a minute. If the number of seconds entered by the user is greater than or equal to 60, the program should display the

1. ### C++

// Program: name of program // Author: your name // Date Written: date you began writing the program /* Abstract: Brief description of the program */ Include in-line comments in the body of your program. You can convert

2. ### Algebra and Maths

In a pest eradication program, "N" sterilized male flies are released into a general population each day. It is estimated that 90% of these flies will survive a give data. A) Show that the number of sterilzed flies in population

3. ### Pre-Algebra

A survey about the student government program at a school finds the following results: 190 students like the program 135 students think the program is unnecessary 220 students plan on running for student government next year. If a

4. ### algebra 2

You buy a used car for \$12,000. It depreciates at a rate of 15% per year. If this trend continues..... a) Write an exponential decay function that models the profit in dollars over time. b) What is the value of the car after 1