Error in Cout statement

I'm getting an error in my second cout line and cant figure our what I'm doing wrong. I thought I declared it right but i'm getting this as my error 23 F:\Leap Year.cpp invalid operands of types `const char[8]' and `<unknown type>' to binary `operator<<' I know its crowded right now I'm working to simplify it this morning though.
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using namespace std;
int leapYear;
int Year;
int a;
int num;



int main()
{
// intro to the program.

cout << " Enter a 2 digit month:" << endl;
cin >> a;

switch (a = 01)
{

cout << num = "January" << endl;

cin >> a;
}
while ( num = 01);

{ 
}
cout << "January" << endl;
    // asking for the year.
    cout << "Please enter a four digit year" << endl;
    // user enters the year.
    cin >> Year;
    leapYear;
    
    
    system("PAUSE");
    return EXIT_SUCCESS;


//int num1 = 01;02;03;04;05;06;07;08;09;10;11;12;

}
while ( num = 02);
else (a = 02);

//while (num = 02)
//
//cout << "February" << endl;
//else if (num = 03)
//
//cout << "March" << endl;
//cout << "April" << endl;
//cout << "May" << endl;
//cout << "June" << endl;
//cout <<"July" << endl;
//cout <<"August" << endl;
//cout <<"September" << endl;
//cout << "October" << endl;
//cout << "November" << endl;
//cout << "December" << endl;


// calculating if the year is a leap-year
int leapYear();
{

    if ((( Year % 4 == 0) && (! ( Year % 100 == 0))) || (( Year % 4 == 0) && (! ( Year % 100 == 0))&&( Year % 400 == 0))) 
{    //return true;
       cout << "It is a Leap-year!" << endl;
  
}
    else
{
        //return false;
       cout << "Sorry... it is not a Leap-year..." << endl;


//cout <<  << "is an invalid selection. \n\n";
     
      }
}
}
}
Note:
Assigning a value to a variable is this: =
The comparing operator is this: ==

Line 19: you're assigning "January" to num. That makes no sense. What are you trying to achieve there?
Was trying to get something like this

User inputs 01
Screen prints January
Line 16: That's not the correct syntax for a switch statement.
Not sure what you're trying to do here. Perhaps something like this:
1
2
3
4
5
6
7
8
9
 
  switch (a)
  {
  case 1: cout << "January";
              break;
  case 2: cout << "February";
              break;
// etc
  }


Line 19: As pointed out previously num = "January" makes no sense. You can;t assign a quoted string to an int.

Line 23: Not sure what this while is supposed to be doing. It looks like you might have intended a do/while loop, but there is no do for the while. If this was intended as the top of a while loop, this will case an infinite loop which does nothing. The semicolon terminates the loop. The condition in the while statement is also incorrect. You're using the assignment operator (=), not the equality operator (==).

Line 25-26: What are these braces for?

Line 41: This } terminates main. Lines 42-43 are outside main.

Line 32: This line does nothing. Did you intended a functioncall? If so, you need ().

Last edited on
Topic archived. No new replies allowed.