Parity of unsigned integer
Submissions: 2103   Accuracy:

60.66%

  Difficulty: Basic   Marks: 1

Given an unsigned integer, find it's parity. Parity of a number refers to whether it contains an odd or even number of 1-bits. The number has “odd parity”, if it contains odd number of 1-bits and is “even parity” if it contains even number of 1-bits.

Input:

2
13
9
Output:

odd
even

Constraints:

1<=t<=100
1<=n<=100
Example:

n = 13 (1101)   parity = 0
n = 13 & 12  = 12 (1100)   parity = 1
n = 12 & 11 = 8  (1000)   parity = 0
n = 8 & 7 = 0  (0000)    parity = 1

 

** For More Input/Output Examples Use 'Expected Output' option **

Author: Yash Goel


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.