// Arup Guha
// 4/25/2024
// Solution to Spring 2024 COP 3502H Final Exam Question 5

#include <stdio.h>

void printRevBin(int n);

int main(void) {

    // Some simple tests.
    for (int i=100; i<120; i++) {
        printRevBin(i);
        printf("\n");
    }
}

void printRevBin(int n) {

    // Only work to do if n is still positive.
    if (n > 0) {

        // Last bit first.
        printf("%d", n%2);

        // Then do the rest.
        printRevBin(n/2);
    }
}
