If-else problem

Hey everybody. I'm writing a code to print a basic tree, with random birds (v) and flowers (o) in it. To randomise this, I'm using a randomly generated number and an if-else statement. The if-else statement however doesn't work as I want it to. I tested it in a separate project to see what the problem is, but whatever number I enter, the program always prints a "o". This is the statement :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>

using namespace std;

int main()
{
    int number;
    cin >> number;
    if (number = 0)
    {
        cout << "v";
    }
    else if (number = 1)
    {
        cout << "o";
    }
    else
    {
        cout << "*";
    }
    return 0;
}

Can anyone tell me what I'm doing wrong here?
Last edited on
You are using = instead of ==. = is for assignment. == is for comparison.
That solved my problem, thanks! :)
Topic archived. No new replies allowed.