wont output right?

the zeller function wont work?
any help please?



#include "stdafx.h"
#include <iostream>
using namespace std;
#include <iomanip>

void output_month(int start, int total) {

cout << " S M T W T F S" << endl;
cout << setw(5 * start ) << "";

int i;
for (i = 1; i <= total; i++) {

cout << setw(5) << i;
if ((i + start) % 7 == 0) {
cout << endl;
}
}

cout << endl;

return;
}
int zeller()


{
int day, month, year;
int result;

if (month < 3)
{
month += 12;
--year;
}

result = day + (13 * month - 27)/5 + year + year/4
- year/100 + year/400;

#ifdef MONDAY_IS_0
result += 6;
#endif // MONDAY_IS_0

return (result % 7);
}



void main()
{

int i = 0;
int j = 0;
int day, month, year;

do {
cout << "Input start: ";
cin >> i;
}
while ((i < 0) || (i > 6));

do {
cout << "Input number of days: ";
cin >> j;
}
while ((j > 31) || (j < 28));

//output_month(i, j);//call
cout<< "enter day";
cin>>day;
cout<<"enter month";
cin>>month;
cout<< "enter year";
cin>>year;
zeller();

system("PAUSE");
}
Double post. Original thread here:

http://www.cplusplus.com/forum/beginner/21016/
1
2
3
4
5
do {
cout << "Input number of days: ";
cin >> j;
} 
while ((j > 31) || (j < 28));


Take a look at your loop conditions again...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
int zeller()


{
int day, month, year;
int result;

if (month < 3) 
{
month += 12;
--year;
}

result = day + (13 * month - 27)/5 + year + year/4
- year/100 + year/400;

#ifdef MONDAY_IS_0
result += 6;
#endif // MONDAY_IS_0

return (result % 7);
}


Day, Month, and Year have not been initialized. I assume what you wanted to do was use the data enter in main. If so you need to pass that data as arguments in your zeller function. Also start using the code tags when posting and clearly state what is wrong with your code.
Topic archived. No new replies allowed.