recategorized by
594 views
3 votes
3 votes

Consider the following C program.

#include <stdio.h>
    main() {
    int arr[] = {1, 1, 2, 4, 8, 16, 32, 64};
    int i, j, val, t = 16;
    unsigned char c;
    for (i = 0; i < 256; i++) {
        c = i;
        val = 0;
        for (j = 0; j < 8; j++)
            val = val + ((c >> j) & 0x1)*arr[j];
            if (val == t)
                printf("%d\n", i);
    }
}

What will be the output of the program? Justify your answer.

recategorized by

1 Answer

0 votes
0 votes
it will print 31 & 32...I THINK
edited by

Related questions