int a ; // i.e. unitialized
int b = 0 ; // i.e. zero
double c = 1.0/0.0 ; // i.e. NaN
In these cases: Simply test it!
Otherwise you have to bee more specific ;-).
Also, is there a code to know if a variable has a value?
I can tell you this is not possible for any integral type since you cannot tell if a certain value was assigned or is still the initial value. You can however if you know your numbers are always positive you can treat variables containing negative numbers as "having no value".
In other cases you will have to use your own class and mark data if it has been set or is still the initial value.