Page Nav

HIDE

Grid

GRID_STYLE

HOW TO CALCULATE THE EVEN ODD USING BIT OPERATOR

     HOW TO CALCULATE THE EVEN ODD USING BIT OPERATOR solution:    #include <bits/stdc++.h> using namespace std; int main(){   long lo...

 


 

 HOW TO CALCULATE THE EVEN ODD USING BIT OPERATOR

solution:

 

 #include <bits/stdc++.h>
using namespace std;

int main(){
  long long  n;cin>>n;
  long long  calc = n&1;
  if(calc ==0){
    cout<<"THE number is even";
  }
  else {
    cout<<"The number is odd";
  }

}

inuput:

99

output:

The number is evenvikash@vikash-HP-Laptop-15-da0xxx:~/Desktop/competative_coding$ g++ a.cpp -o a
vikash@vikash-HP-Laptop-15-da0xxx:~/Desktop/competative_coding$ ./a
10


THE number is even

vikash@vikash-HP-Laptop-15-da0xxx:~/Desktop/competative_coding$ ./a
90
THE number is even

vikash@vikash-HP-Laptop-15-da0xxx:~/Desktop/competative_coding$ ./a
99
The number is odd

vikash@vikash-HP-Laptop-15-da0xxx:~/Desktop/competative_coding$ ^C

=================================================

the video tutorial for better understanding :