How to find out if nth bit of a number is set to 1?

#include <stdio.h>
int main()
{
int val1 = 4;
int val2 = 18;
int mask = 1;
/* mask <<= 4; */
mask = mask << 4;
printf("mask is %d\n",mask);
if ( val1 & mask ) {
printf("Bit 5 in val1 is set\n");
}
if (val2 & mask ) {
printf("Bit 5 in val2 is set\n");
}
}