0

How to find even or odd number

I'm beginniner plzz help me

10th Oct 2017, 5:15 AM
Sachin Popalghat
Sachin Popalghat - avatar
4 odpowiedzi
+ 11
#include <iostream> using namespace std; int main() { int n; cout << "Enter the any number: "; cin >> n; if ( n % 2 == 0) cout << n << "\ngiven no is even."; else cout << n << "\ngiven no is odd."; return 0; }
10th Oct 2017, 5:17 AM
IMRAN SHAIKH
IMRAN SHAIKH - avatar
+ 11
Same result using bitwise AND operator as the odd checker. #include<iostream> using namespace std; int main () { int n = 0; cout << "Number is: "; cin >> n; if (n & 1) cout << "Odd.\n"; else cout << "Even.\n"; }
10th Oct 2017, 5:36 AM
Babak
Babak - avatar
16th Oct 2017, 11:36 AM
Paritosh
0
thnks
10th Oct 2017, 5:18 AM
Sachin Popalghat
Sachin Popalghat - avatar