Shoubhik, what compiler are you using? I think the line:

>>       int *p=∑

Should not compile per the standard. See http://ideone.com/ujHY5

prog.cpp:5: error: invalid conversion from ‘const int*’ to ‘int*’
Happy New Year, Gregorian Calendar observers!

Barış

On 2 Jan 2012, at 07:48, mandeep <[email protected]> wrote:

> Well,p points to address of variable sum and when we change value of
> *p,then it change value at that address,thats why u got this output.
> 
> On 1/2/12, Shoubhik <[email protected]> wrote:
>> 
>> int main()
>> {
>>        int const sum=100;
>>        int *p=&sum;
>> 
>>        *p=101;
>> 
>> 
>>        printf("%d, %d",*p,sum);
>>        return 0;
>> }
>> 
>> /*
>> 
>> output
>> 
>> 101, 101
>> 
>> */
>> 
>> p points to a constant integer variable, then why/how does *p manage
>> to change the value of sum?
>> 
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google Code Jam" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/google-code?hl=en.
>> 
>> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Google Code Jam" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/google-code?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-code?hl=en.

Reply via email to