voltagejim3000
March 3rd, 2008, 12:56 PM
I have a program that is almost done, but I have 2 errors that I cannot figure out what they are. I have been looking for an hour, and can come up with no solution! The program I am doing is supposed to take the users inputed month and year, and output the days in the month and whether it is a leap year or not. Here is the code:
#include<iostream>
using namespace std;
bool isleap(int);
int daysinmonth(int);
void main()
{
int year;
int month;
cout << "Enter the month: ";
cin >> month;
cout << "Enter the year: ";
cin >> year;
while (!cin.eof())
{
if (isleap(year))
{
cout << year << " Leap year" << endl;
cout << "There are " << daysinmonth << " days in the month of " << month << " during leap year" << endl;
}
else{
cout << year << " Not a leap year" << endl;
cout << "There are " << daysinmonth << " days in the month of the month of " << month << endl;
}
cout << "Enter the year: ";
cin >> year;
cout << "Enter the month: ";
cin >> month;
}
}
bool isleap(int y)
{
if ((y%4 == 0 && y%100 != 0) || (y%400 == 0))
return true;
else
return false;
}
int daysinmonth(int year, int month)
{
if (month == 1 || month == 3 ||month == 5 ||month == 7 || month == 8 || month == 10 || month == 12){
return 31;
}
else if(month == 4 || month == 6 || month == 9 || month == 11) {
return 30;
}
else if (isleap(year) && month == 2){
return 29;
}
else
return 28;
}
The errors are :
1>month.obj : error LNK2019: unresolved external symbol "int __cdecl daysinmonth(int)" (?daysinmonth@@YAHH@Z) referenced in function _main
1>E:\month\Debug\month.exe : fatal error LNK1120: 1 unresolved externals
#include<iostream>
using namespace std;
bool isleap(int);
int daysinmonth(int);
void main()
{
int year;
int month;
cout << "Enter the month: ";
cin >> month;
cout << "Enter the year: ";
cin >> year;
while (!cin.eof())
{
if (isleap(year))
{
cout << year << " Leap year" << endl;
cout << "There are " << daysinmonth << " days in the month of " << month << " during leap year" << endl;
}
else{
cout << year << " Not a leap year" << endl;
cout << "There are " << daysinmonth << " days in the month of the month of " << month << endl;
}
cout << "Enter the year: ";
cin >> year;
cout << "Enter the month: ";
cin >> month;
}
}
bool isleap(int y)
{
if ((y%4 == 0 && y%100 != 0) || (y%400 == 0))
return true;
else
return false;
}
int daysinmonth(int year, int month)
{
if (month == 1 || month == 3 ||month == 5 ||month == 7 || month == 8 || month == 10 || month == 12){
return 31;
}
else if(month == 4 || month == 6 || month == 9 || month == 11) {
return 30;
}
else if (isleap(year) && month == 2){
return 29;
}
else
return 28;
}
The errors are :
1>month.obj : error LNK2019: unresolved external symbol "int __cdecl daysinmonth(int)" (?daysinmonth@@YAHH@Z) referenced in function _main
1>E:\month\Debug\month.exe : fatal error LNK1120: 1 unresolved externals