Function prototype problems

not exactly sure what I am doing wrong here...

advice?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//******************************************************************
// LeapYear program
// This program inputs at year and prints whether the year 
// is a leap year or not
//******************************************************************

#include <iostream>		// Access output stream

using namespace std; 

bool isLeapYear( int );		// Prototype for subalgorithm	
 
int main() {
    int year;
    cout << "Enter a year AD, for example, 1997." 
      << endl;  		// Prompt for input
    cin >> year;                   // Read year
  
    if (isLeapYear ( year ) )          // Test for leap year
        cout << year << " is a leap year."  << endl;          
    else 
        cout << year << " is not a leap year."  << endl;
  
    return 0;
}

// *****************************************************************

bool isLeapYear( int year )
// IsLeapYear returns true if year is a leap year and
// false otherwise.

{
    if (year % 4 != 0)            // Is year not divisible by 4?
        return false;             // If so, can't be a leap year
    else if (year % 100 !=  0)    // Is year not a multiple of 100?
        return true;              // If so, is a leap year
    else if (year % 400 != 0)     // Is year not a multiple of 400?
        return false;		    // If so, then is not a leap year
    else 
        return true;              // Is a leap year
}
Last edited on
Use code tags: http://cplusplus.com/articles/z13hAqkS/

And what's the error?
two errors


_main already defined

fatal error LNK1169: one or more multiply defined symbols found
Try making the program again in a different project. The code worked for me.
that did it.

thanks.

Topic archived. No new replies allowed.