Lab: questions about C integers

Here's a list of questions. For each question, show how to answer the question by writing a little C code.

A handy tool

If you want to know the exact bits contained in an int, do this:

int j = whatever; printf("0x%08X\n", j);

It gets slightly weirder for long (note the l before the X)

long k = whatever; printf("0x%016lX\n", k);

It gets even weirder for char. See below.

The questions