//------------------------------------------------------------------- // google.cpp // // This program is just a test-stub for an assembly language // solution to the job-interview question asked by Nicholas. // // to compile: $ g++ google.cpp nicholas.s -o google // to execute: $ ./google // // programmer: ALLAN CRUSE // written on: 06 MAY 2008 //------------------------------------------------------------------- #include // for printf(), perror() extern "C" int bit_total( short *array, int words ); int main( int argc, char **argv ) { int words = 10; short array[ ] = { 1, 2, 4, 8, 3, 6, 9, 12, 7, 14 }; int n_bits = bit_total( array, words ); printf( "The number of set bits is %d \n", n_bits ); }