# Thread: basic C-programming Q

1. ## basic C-programming Q

/* I'm new to this and am wondering why the output of this is what it is: */

int main()
{
int number;
number= 23 + 023 + 0x23;
printf("The numbers: %d\n",number);
}

/* obviously "23" =23.
I don't know why "023" = 19.
I don't know why "0x23" = 35.

Is there someone who can explain this concept for me?
Thanks */ 2. ## Re: basic C-programming Q

Originally posted by slyonedoofy
/* I'm new to this and am wondering why the output of this is what it is: */

int main()
{
int number;
number= 23 + 023 + 0x23;
printf("The numbers: %d\n",number);
}

/* obviously "23" =23.
I don't know why "023" = 19.
I don't know why "0x23" = 35.

Is there someone who can explain this concept for me?
Thanks */

"0x23" == is hexdec.
"023" == hexdec ? or octal (try to find out on calculator)

two of the num change to decimal num and then sum up and store it on variable "number". that's all. 3. Hey,
thanks a bunch.
now I got it.

the 0x23 is hexidecimal (16*2)+3=35
the 023 is octal (8*2)+3=19

thanks for the help! Popular pages Recent additions 