very simple program lvalue required

I get lvalue required in if statement.. but can't figure out what's wrong. Thanks.

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
#include<iostream>
#include<conio>
int main()
{
int num = 0, even = 0, odd = 0;

while(num < 100)
   {
   num = num + 1;
   cout<<num;

   if(num % 2 = 0)
      {
      even = even + num;
      }

   if(num % 2 = 0)
      {
      odd = odd + num;
      }
   }
cout<<"Even: "<<even<<endl;
cout<<"Odd: "<<odd<<endl;

return 0;
getch();
}
This num % 2 = 0 assigns 0 to the calculation. You certainly want to compare:

num % 2 == 0

== for comparing
= for assigning
haha how could i be so dumb.. thanks!
Topic archived. No new replies allowed.