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.
 👍
 👎
 👁
 ℹ️
 🚩
2 answers

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
 👍
 👎
 ℹ️
 🚩
answered by Samfford 
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. 👍
 👎
 ℹ️
 🚩
answered by MathMate
Answer this Question
Related Questions

Algebra
Robin bought a computer for $1,250. It will depreciate, or decrease in value, by 10% each year that she owns it. a. Is the sequence formed by the value at the beginning of each year arithmetic, geometric, or neither? Explain. b. Write an explicit formula
 asked by heyo ❄
 1,396 views

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 loop to ask the user how
 asked by Anonymous
 3,603 views

Engineering Economy
A young engineer wishes to become a millionaire by the time he is 60yrs old. He believes that by careful investment he can obtain a 15% rate of return. he plans to add a uniform sum of money to his investment program each year, beginning on his 20th
 asked by John
 1,566 views

social studies
Earth's position in space at any point in the year determines the A. season B. time of day C. annual percipitation D.climate Help Ms. Sue please
 asked by julius connections academy is the best
 3,566 views

C programming
Question: Write a program that reads integers from the keyboard until the user enters the sentinel value 999. The program should then print the minimum integer read, the maximum integer read and the average of all the integers. (Excluding the sentinel
 asked by E
 6,423 views

programming logic
Find Bugs in the pseudocode // A high school is holding a recycling competition // This program allows a user to enter a student's // year in school (1 through 4) // and number of cans collected // Data is entered continuously until the user wnats to quit
 asked by tina
 1,681 views

calculus
A model for the length of daylight (in hours) in Philadelphia on the tth day of the year is L(t) = 12 + 2.8 sin 2π/365(t − 80) . Use this model to compare how the number of hours of daylight is increasing in Philadelphia on April 21 and June 5. (Assume
 asked by ken
 2,790 views

programming
A hotel’s occupancy rate is calculated as follows: Occupancy rate = number of rooms occupied total number of rooms Write a program that calculates the occupancy rate for each fl oor of a hotel. The program should start by asking for the number of fl oors
 asked by AB
 3,873 views

algebra 1A
a family travels to Bryce Canyon for three days. on the first day, they drive 150 miles. on the second day, they drive 190 miles. what is the least number of miles they drove on the third day if their average number of miles per day was at least 180?
 asked by loraine
 1,009 views

Cmin
Draw a flowchart and write pseudocode to represent the logic of a program that allows the user to enter two values. The program outputs the sum of and the difference between the two values.
 asked by Jo
 2,512 views

Statistics
The number of ships to arrive at a harbor on any given day is a random variable represented by x. The probability distribution of x is as follows. (Give your answers correct to two decimal places.) x 10 11 12 13 14 P(x) 0.37 0.09 0.05 0.14 0.35 (a) Find
 asked by Gayle
 3,566 views

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. Display what the
 asked by Ant
 2,766 views

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 pseudocode
 asked by Siya
 3,759 views

Pseudocode
Write an algorithm and pseudocode for A salesperson wants to write a program to calculate their gross monthly pay based on their annual salary, total sales, and commission rate. The program's output is the monthly pay calculated by: Monthly pay = (annual
 asked by Mare
 2,010 views

Math
On what day in the year 1943 was the year 300 000 minutes old?
 asked by Pam
 2,952 views

Programming
Write a program (pseudocode) that would calculate and display the results for the multiplication table for values ranging from 1 to 100. This what I have so far: Declare X, Y, Z As Integer Write “10 x 10 Multiplication Table” For (X = 1; X
 asked by Amanda
 5,275 views

Mathplease check!
1. Which of the following are continuous random variables? (select all that apply) a. The distance a person has walked in a day b. How many glasses of water a person consumes in a day c. The number of steps a person has walked in a day d. The time it takes
 asked by cat
 715 views

computer
Write an algorithm for a program that accepts a set of numbers and finds the smallest among them and computes the sum of the numbers accepted. The program stops when the user enters number 999. Convert the algorithm into flowchart
 asked by Anonymous
 1,944 views

C++
A small business wants to create a file to store its customer information. Each record in the file is to contain the following data: customer ID number, first name, last name, city, zip code, and account balance. Write a program to create such a customer
 asked by noone
 264 views

Programming
Write a pseudocode to represent the logic of a program that allows a user to enter an hourly pay rate and hours worked. The program outputs the user's gross pay
 asked by Sunshine
 10,741 views
Still need help?
You can ask a new question or browse existing questions.