oops a little mistake....i got 101,100 output for the following program written in C. so here *p again unable to manage value of variable sum.
I think it's not possible to change the value of variable const sum. u can check it out on this link http://codepad.org/ #include <stdio.h>int main(){ int const sum=100; int *p=∑ *p=101; printf("%d, %d",*p,sum); return 0;} On Mon, Jan 2, 2012 at 6:57 PM, Baris Acar <[email protected]> wrote: > 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=∑ > > > *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. > -- 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.
