How can I get a variable in C whose value should be only from 20 to 520?
In C there is no such data type.
Even if the range was something close to the boundaries of some types, the danger of overflow or overflow would be all the same (imagine an unsigned int , for example, where you want the lower border to be 0, but someone might exceed this binding).
What you can do is write your own structures, accessors and / or listings to achieve this. If interested, read Paul R's answer. However, I do not urge you to do this.
I would do this if, for example, the variable had to be populated by the user:
int v; do { scanf("%d", &v); } while(!(v >= 20 && v <= 520));
so that the user requests again and again until his input meets the criteria.
PS: That sounds like an XY question.
source share