I'm extremely new to c++- this is a homework question- I do not understand how to write my program for this problem:

Write a function named yrCalc() that has an interger parameter representing the total number of days since the turn of the last century (1/1/1900) and reference parameters named year, month, and day. The function is to calculate the current year, month, and day for the given number of days passed to it. Using the references, the function should directly alter the respective actual agruments in the calling function. for this problem, assume that each year has 365 days and each month has 30 days.

I do not know how to figure out the calculation but, this is what I know so far which is not much:

#include <iostream>
using namespace std;

void yrCalc [double& year, double& month, double& day];

int main()
[
double year, month, day;
int numdays =


Please help!

Recommended Answers

All 2 Replies

You've declared a function with the correct name and correctly accepts reference parameters but you've forgotten the integer parameter.

Initialize numDays to zero but putting a zero after the assignment operator.

To have the user input a number of days use cout to prompt them to enter a number and cin to store the value in numdays.

Then you need to define the function by writing out what you want the function to do in the funciton body.

Next you want to call the function from within main().

Then you want to display the new values of the appropriate parameters before the program quits.

Your question syas that the function must have a integer parameter representing the number of days past from 1/1/1990. where's that in your code so far???
Your function is still accepting three parameters for the date 1/1/1990.

I think it should like this:

void yrCalc(int &day,int &month,int &year,int days_past)

where days_past are number of days past from 1/1/1990.

Try to compute the final date using this parameter.Start by checking whether days_past>=365.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.