What is FAULTS IN MY CODE FOR problem code "BITMAGIC" please help

#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t–)
{
int n,k,ans;
cin>>n>>k;
if(n&(1<<k)==0)
{
ans=n|(1<<k);
cout<<ans<<endl;
}
else ans=n;
cout<<ans<<endl;
}
return 0;
}

Can you share the problem link?

#include<bits/stdc++.h>
using namespace std;
int main()
{
      int t;
     cin>>t;
    while(t–-){ // should be t--
  int n,k,and;
  cin>>n>>k;
   if(n&(1<<k)==0){
  ans=n|(1<<k);
  cout<<ans<<endl;
   }
else ans=n;
cout<<ans<<endl;
}
return 0;
}
2 Likes

Hi. Try doing
((n & (1 << k)) == 0).

Try using proper parenthesis in bitwise operators.