title: Write A C Program To Find The Parity Of An Unsigned Integer
signature: writeACProgramToFindTheParityOfAnUnsignedInteger(n) {
test_code: import 'dart:convert';
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  bool validateSolution(int actual, int expected){
      return actual.toString() == expected.toString();
  }
  
  String driver(n, int expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(n), expected)){
              return "PASSED";
          }
          return "FAILED";
      }catch(exception_object){
          return exception_object.runtimeType.toString();
      }
  }
  
  int main() {
  
      print("TEST-0...${driver(
          63, 
          0)
      }");
  
      print("TEST-1...${driver(
          64, 
          -1)
      }");
  
      print("TEST-2...${driver(
          85, 
          0)
      }");
  
      print("TEST-3...${driver(
          36, 
          0)
      }");
  
      print("TEST-4...${driver(
          20, 
          0)
      }");
  
      print("TEST-5...${driver(
          63, 
          0)
      }");
  
      print("TEST-6...${driver(
          42, 
          -1)
      }");
  
      print("TEST-7...${driver(
          19, 
          -1)
      }");
  
      print("TEST-8...${driver(
          62, 
          -1)
      }");
  
      print("TEST-9...${driver(
          97, 
          -1)
      }");
  
      return 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;
  }