[Help] Just started learing C++ and I have no idea why this code doesn't work

I've just started learning C++ and I have no clue why this code isn't working when I change the FavNum value to something else it still only outputs "That's my favourite number!" even when I change FavNum to somehting other than 6.


http://goo.gl/8OZGaU < Here's what i'm using to code at the moment, does any one know a good IDE for me to use?

Thanks in advance :D

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
#include <iostream>
#include <vector>
#include <string>
#include <fstream>


using namespace std;

int main(){
    
    int FavNum = 20;
    
    
    if(FavNum = 6){ cout<<"That's my favourite number!"<<endl;}
    
    else if(FavNum!= 20){cout<<"That's an okay favourite number I guess"<<endl;}
    
    else if(FavNum!= 1){cout<<"D:"<<endl;}
    
    
    
    return 0;
    
    
}
FavNum = 6

You're confusing the assignment operator = with the equality comparison operator ==.
This fixed it - Thanks alot!
You're welcome :)
Topic archived. No new replies allowed.