yearCalc help

Hi I have a program that has an integer parameter representing the total number of days from the date 1/1/2000 and reference parameters. It is supposed to calculate the current year, day,and month give the number of days passed to it. Does anyone know why it is not outputting correctly? I think it has something to do with the cout and cin inside the void yrCalc function.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
using namespace std;

void yrCalc(int totalDays, int& yr, int& mon, int& day) {
    yr= 2000 + totalDays / 365;
    totalDays -= yr * 365;
    // ... calculate mon and day ...
    mon=(totalDays%365)/30;
    day=(totalDays%365)-(mon*30);
  cout<<"please enter the number of days"<<endl;
  cin>>totalDays<<endl;
}

int main() {
    int yr, mon, day;
    yrCalc(40000, yr, mon, day);

    cout << yr << " - " << mon << " - " << day << endl;
}
Last edited on
Line number 11.

You are using the insertion operator << in a cin statement. Does that even compile?
okay so would i cin>>day instead or make another variable called num to cin?
Topic archived. No new replies allowed.