#include <stdio.h>

/* Terry Harvey CISC105 Section TA*/

/* Start with a number
 * Find largest pow of 2 that fits into it
 * write 1
 * subtract powOf2 from number to get newNum
 * compare newNum to next power (powOf2 / 2)
 *         write 1 if <=
 *         0 otherwise
 * 
 */

int main(){
    int decimal, newNum;
    int powerOf2 = 2;
    decimal = 29;

    /* find largest power */
    while (powerOf2 <= decimal)
	powerOf2 = powerOf2 * 2;   /* powerOf2 *= 2; */

    powerOf2 = powerOf2 / 2;
    printf("powerOf2 is %d\n", powerOf2);

    /* print binary equivalent */

    printf("1");
    newNum = decimal - powerOf2;

    while(){ //fill in an appropriate condition
	powerOf2 = powerOf2 / 2;
	if (newNum < powerOf2)
	    printf("0");
	else {
	    printf("1");
	    newNum = newNum - powerOf2;
	}
    }

    printf("\n");
    return 0;
}
