The problem is simple, and the error message already hinted as to what it is. Line 9 is as follows:
else cout<<a&(-a)<<endl;
Now you probably think that this line is supposed to be parsed as (note extra parentheses) this:
else cout<< (a&(-a)) <<endl;
However, it's being parsed as this:
else (cout<<a) & ((-a)<<endl);
The compiler doesn't know what to do with the expression (-a)<<endl
. The left-hand side of the expression, (-a)
, is an int
, while the right-hand side, endl
, is what the compiler sees as an <unresolved overloaded function type>
, hence the error message.
There are several other problems with your code.
Never use #include <bits/stdc++.h>
. It is non-standard and only works with some compilers: Why should I not #include <bits/stdc++.h>?
The declaration for function main()
is wrong. Its return type must be an int
. Anything else is non-standard: What is the proper declaration of main in C++?
The expression a==a&(-a)
may not do what you want. You may think that it means a == (a&(-a))
(again, note extra parentheses), when instead it means (a==a) & (-a)
.