What error is this??

Hello everyone! I am a beginner in C++. I am doing a very simple program.As simple it could be i get a error.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream.h>
#include <math.h>
using namespace std;
int main ()
{
	unsigned n,i;
	cout<<"n=";cin>>n;
	for (i=2;i<=n/2;i++)
	{
		if (n%i=0) cout<<"i="<<i;/*<=====This is where the error is*/
	}
	system ("pause");
	return 0;
	

}	
	

and the error I get is this one:
5 II.cpp:10: error: non-lvalue in assignment


Thank you for your taking your time helping me :)
= is the assignment operator
== is the equality operator
Change n%i=0 to n%i==0
Yes, this if (n%i=0) is an assignment. What you certainly want is a comparison: if (n%i==0)

Take care of the difference between = (assignment oprator) and == (comparison oprator)
yep.It works now,Thank you
Topic archived. No new replies allowed.