jeudi 28 janvier 2021

use of "&" operator in conditional statement in C++ [duplicate]

int main()
int n=5;
if(n & 1)
cout<<"odd";
else
cout<<"even";

how we are getting even or out using "&" operator it should have been like this

if(n%2!=0) to check the even or odd. can anyone explain what is that code doing.

Aucun commentaire:

Enregistrer un commentaire