512
Because:
a will have the binary value of 256.
a is an integer, so it will be stored over 4 bytes like this:

a
0000  0001 0000 0000
byte1 byte2 byte3 byte4

now a char pointer with point to one byte., and here the first byte.

p
\/
0000  0001 0000 0000
byte1 byte2 byte3 byte4

incrementing p will make it point to the second byte

            p
            \/
0000  0001 0000 0000
byte1 byte2 byte3 byte4

Assigning 2 to the value of p will change the data which is 0001 to 0010 (2
in binary)
hence making:

a
0000  0010 0000 0000
byte1 byte2 byte3 byte4

which is binary for 512

On Thu, Sep 22, 2011 at 6:02 PM, Yogesh Yadav <medu...@gmail.com> wrote:

> Ans. 512
>
> ...
>
>
> On Thu, Sep 22, 2011 at 5:38 PM, Rohit Upadhyaya 
> <mailtoroh...@gmail.com>wrote:
>
>> int main()
>> {
>> int a=256;
>> char *p=&a;
>> *++p=2;
>> printf("%d",a);
>> return(0);
>> }
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Anup Ghatage

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to