Very basic "sleep calculator" algorithm in C using cs50 library
A few things:


Naming: b and w aren't particularly descriptive.  Even bampm and wampm are better.
You've got extra {} around your if statement for some reason.
Your algorithm does a lot of tests.  What if you convert to 24-hour time?

Doing so will let you get rid of b and w by changing bedtime and wakeup after you read them.

printf("When did you go to bed last night?\n");
int bedtime = GetInt();
// determine AM or PM
printf("AM [1]\nor\nPM [2]\n");
int ampm = GetInt();
// convert to 24-hour time
if (ampm == 2) bedtime = bedtime + 12;
// get user wake up time
printf("When did you wake up this morning?\n");
int wakeup = GetInt();
// determine AM or PM
printf("AM [1]\nor\nPM [2]\n");
ampm = GetInt();
// convert to 24-hour time
if (ampm == 2) wakeup = wakeup + 12;


Also, the conditionals get easier:

int slept = wakeup - bedtime;
if (slept &lt; 0) { slept = slept + 24 } // math is your friend
printf("You slept for %i hours last night\n",slept);

Once principle of programming is "Don't Repeat Yourself" aka "DRY".  Do you really need 3 copies of the output printf?

Of course not.  You can move it after the end of the if statement.
Finally, I don't know if this was covered in class, but you're not doing any input checking.  What if the user puts in 3 instead of 1 or 2 ?  What if they put in times like -5 or 27 ?