thanks got it...i was actually thinking in some other way.... so basically everything is actually stored in binary form.it's for our convenience and readability that we are converting them to hex or decimal..... so suppose... unsigned int i=10 printf("%x",i) //this will print the hex equivalent of 10? On 6/7/12, Ángel González <keisial@xxxxxxxxx> wrote: > On 06/06/12 19:14, dhpant2806 wrote: >> i want to test some code having hex variable in gcc.how can i do it > What do you mean? Your question doesn't make much sense. > You don't have 'hex' variables. The way the values are stored is specific > to the architecture you are compiling to (just think that they are > "stored as bits"). > Decimal, hexadecimal, binary, etc. is how we input them (in writing the > literals) > or output them. > > I have no idea if this is what you wanted, but take a look at the > following program: > > #include <stdio.h> > > int main() { > int variableA = 42; > int variableB = 0x33; > printf("Variable A: %d decimal - %x hexadecimal\n", variableA, > variableA); > printf("Variable B: %d decimal - %x hexadecimal\n", variableB, > variableB); > return 0; > } > >