& is a binary AND, not a logical AND - to combine two conditions like this this:
(a == b) AND (c == d)
You need the logical AND operator which is two ampersands: &&
(a == b) && (c == d)
Please do yourself a favour and be consistent in your bracket usage and indentation: pick a single style and use it throughout.
When you get code like this:
int main()
{
...
for(...){
if(...)
...
if(...)
...
}
...
...
}
It shows you don't care about what you are doing, and makes code very hard to read. Pick a style, be consistent:
int main(){
...
for(...){
if(...)
...
if(...)
...
}
...
...
}
Ugly, horrible and vile though it is. Get the indentation wrong, and it's a PITA to work out where the missing bracket is or should be ...
Or
int main()
{
...
for(...)
{
if(...)
...
if(...)
...
}
...
...
}
Commonly used. Much better.
Or
int main()
{
...
for(...)
{
if(...)
...
if(...)
...
}
...
...
}
My preference - Whitesmiths.
In addition, I'd strongly recommend that as a beginner you
always use curly brackets, even when they aren't strictly necessary - if you don't it can make for strange bugs later when you edit it!
int main()
{
...
for(...)
{
if(...)
{
...
}
if(...)
{
...
}
}
...
...
}
It may seem irrelevant, but after you've spent a couple of hours trying to work out why this doesn't work
if (a == b)
c = c + 1;
d = d + 10;
And realize it should be
if (a == b)
{
c = c + 1;
d = d + 10;
}
you will see why it's a good idea!