Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Question 02: Write a modular C program to compute and display the day-number in a year for a date that is input at the keyboard. A day-number for a date is the number of days from 1st January of the date's year to the date. For example: The day number of 3rd February is 34, the day number of 5th March is 64 if the year is a non-leap year; otherwise it is 65 (A leap year is a year that has 366 days; a non-leap year has 365 days).

Your program must check for input validity. It must display an appropriate error message and terminate if the three inputs for date (day, month, and year) do not form a valid date.

In addition to the main function your program must use the following functions:

  • A function that displays the following message to the user:

         "This program computes and displays the day number of a date input as:  day   month   year."

  • Abooleanfunction (implemented as anintfunction) that tests for input validity. The function returns 1 if the three inputs form a valid date; otherwise it returns zero. This function must not haveprintforscanfcalls.
  • Abooleanfunction (implemented as anintfunction) that returns 1 if its parameter year is a leap year; otherwise it returns 0 (A leap year is a year that has 366 days). This function must not haveprintforscanfcalls.
  • Anintfunction that returns the day-number of a particular date. This function must not haveprintforscanfcalls.

Note:

  • A year is a leap year if it is divisible by 400; otherwise if it is divisible by 4andnot divisible by 100.
  • Assume a year is between 1900 and 3000 inclusive, i.e.,1900 ≤ year ≤ 3000
  • Your program must be general.
  • For grading purposes, each non-main function must be written after the main.
  • Your program must behave as the sample program runs below.
  • You may use the table of day-numbers given below to test your program.

Sample program runs:



Date

Day number

Comment

February 29, 2015

invalid

2015 is not a leap year

March 27, 2015 (Fri)

Day 86

 

April 9, 2016 (Sat)

Day 100

2016 is a leap year

September 14, 2016 (Wed)

Day 258


Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91668918

Have any Question?


Related Questions in Computer Engineering

When we look at the ease to enter the different market

When we look at the ease to enter the different market structure, there is no doubt that 'monopoly' is the hardest. Why? -- There is only ONE firm that has established 'economies of scale' with the production of their go ...

From the following information how would i work out the

"From the following information, how would I work out the standard error of the estimate for the regression model (in excel)? Multiple R=0.7545, Adjusted R Square=0.5077, Regression df=1, Residual df=7 SS=27.37 MS=3.91, ...

1 the economy is in a recession with high unemployment and

1) The economy is in a recession with high unemployment and low output (i.e. the output currently is lower than the natural level of output) a) Draw a graph of aggregate demand and aggregate supply to illustrate the curr ...

If we compare and contrast the four market structures it is

If we compare and contrast the four market structures, it is evident that one market structure is most practiced and evident in the United States. It is the one that promotes and strives on competition. It is the one tha ...

Select two application areas for data mining not discussed

Select two application areas for data mining NOT discussed in the text book and briefly discuss how data mining is being used to solve a problem (or to explore an opportunity)?

Given a list of numbers l a value x is said to be a

Given a list of numbers L, a value x is said to be a majority value if the value of over half the elements in L is x; in other words, if L has n elements and nx is the number of elements in L with value x, then x is a ma ...

Need help with a java program that takes two arrays a and b

Need help with a Java program that takes two arrays a and b of length 5 storing int values, and returns the dot product of a and b. That is, it returns an array c of length n such that c[i]=a[i]*b[i].

In linux what synchronization methods they use within the

In Linux what synchronization methods they use within the kernel, please dig into your findings for Linux.

Question define and briefly discuss the following

Question: Define and briefly discuss the following brainstorming techniques, the delphi technique, brainstorming, or nominal group technique. 1. you are required to write an initial post (300 words). 2. Also discuss adva ...

Respond to the followingin a bst what is the complexity

Respond to the following: In a BST, what is the complexity required to remove the minimum element? In a BST, what is the complexity required to find (but not remove) the minimum element? In a heap, what is the complexity ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As