title: Write A C Program To Find The Parity Of An Unsigned Integer
signature: def write_a_c_program_to_find_the_parity_of_an_unsigned_integer(n):
test_code: import array
  import bisect
  import collections
  import datetime
  import functools
  import heapq
  import itertools
  import math
  import queue
  import re
  import string
  import sys
  from typing import Any, Dict, List, Optional, Set
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  def validate_solution(actual, expected):
      return actual == expected
  
  def driver(n, expected):
      try:
          if validate_solution(PLACEHOLDER_FN_NAME(
              n),
              expected
          ):
              return "PASSED"
          return "FAILED"
      except Exception as exception_obj:
          return type(exception_obj).__name__
      
  if __name__ == "__main__":
      result = driver(63, 0)
      print(f"TEST-0...{result}")
  
      result = driver(64, -1)
      print(f"TEST-1...{result}")
  
      result = driver(85, 0)
      print(f"TEST-2...{result}")
  
      result = driver(36, 0)
      print(f"TEST-3...{result}")
  
      result = driver(20, 0)
      print(f"TEST-4...{result}")
  
      result = driver(63, 0)
      print(f"TEST-5...{result}")
  
      result = driver(42, -1)
      print(f"TEST-6...{result}")
  
      result = driver(19, -1)
      print(f"TEST-7...{result}")
  
      result = driver(62, -1)
      print(f"TEST-8...{result}")
  
      result = driver(97, -1)
      print(f"TEST-9...{result}")
  
      sys.exit(0)
source_py: def write_a_c_program_to_find_the_parity_of_an_unsigned_integer(n):
      parity = 0
      while n:
          parity = (~ parity)
          n = (n & (n - 1))
      return parity
source_cpp: bool write_a_c_program_to_find_the_parity_of_an_unsigned_integer(unsigned int n) {
    bool parity = 0;
    while ( n ) {
      parity = ! parity;
      n = n & ( n - 1 );
    }
    return parity;
  }