Having trouble with else if codes

So my professor gave me a basic assignment, to make a program that will display a student's year level depending on if they enter 1, 2, 3, or 4. But the problem is, no matter which of those numbers I enter, the program keeps displaying "Freshmen" and neither of the other ones. I don't know what I'm doing wrong.

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
#include <iostream>
using namespace std;
int main()
{
	int num1;
	
	cout<<"Enter number: ";
	cin>>num1;
	
	if (num1 = 1)
	{
		cout<<"Freshmen";
	}
	
	else if (num1 = 2)
	{
		cout<<"Sophomores";
	}
	
	else if (num1 = 3)
	{
		cout<<"Juniors";
	}
	
	else if (num1 = 4)
	{
		cout<<"Seniors";
	}
	return 0;
}
= is used for assignment.
== is used for comparison.
Well, now I feel a bit stupid. Could swear I tried that before and all I got was a compiler error. Anyways, thanks for the quick reply! Program works now!
the "=" (assignment operator) should be "==" (comparison operator)
Topic archived. No new replies allowed.